Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting S3 objects' last modified datetimes with boto

I'm writing a Python script that uploads files to S3 using boto librairy. I only want to upload changed files (which I can check by their "last modified" datetimes), but I can't find the Boto API endpoint to get the last modified date.

like image 369
vreal Avatar asked Mar 13 '12 06:03

vreal


People also ask

What is boto3 resource (' S3 ')?

​Boto3 is the official AWS SDK for Python, used to create, configure, and manage AWS services. The following are examples of defining a resource/client in boto3 for the Weka S3 service, managing credentials, and pre-signed URLs, generating secure temporary tokens, and using those to run S3 API calls.

What does S3 Getobject return?

Retrieves objects from Amazon S3. To use GET , you must have READ access to the object. If you grant READ access to the anonymous user, you can return the object without using an authorization header. An Amazon S3 bucket has no directory hierarchy such as you would find in a typical computer file system.

Does Put_object overwrite?

If an object already exists in a bucket, the new object will overwrite it because Amazon S3 stores the last write request.

What is the difference between boto3 client and resource?

00:00 Boto3's primary function is to make AWS API calls for you. It extracts these APIs in two main ways: clients and resources. Clients give you low-level service access, while resources provide an object-oriented way of working with these services.


1 Answers

Here's a snippet of Python/boto code that will print the last_modified attribute of all keys in a bucket:

>>> import boto >>> s3 = boto.connect_s3() >>> bucket = s3.lookup('mybucket') >>> for key in bucket:        print key.name, key.size, key.last_modified index.html 13738 2012-03-13T03:54:07.000Z markdown.css 5991 2012-03-06T18:32:43.000Z >>> 
like image 140
garnaat Avatar answered Sep 21 '22 02:09

garnaat