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.
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.
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.
If an object already exists in a bucket, the new object will overwrite it because Amazon S3 stores the last write request.
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.
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 >>>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With