How can I get last modified datetime of S3 objects with boto?

I'm writing a python scripts to upload files to s3 using boto. I want to only upload changed files which I can check by it's last modified datetime. But I can't find the api to get the last modify in boto API.

Answers 1

  • 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.size, key.last_modified
    index.html 13738 2012-03-13T03:54:07.000Z
    markdown.css 5991 2012-03-06T18:32:43.000Z

Related Articles