Skip to content

Instantly share code, notes, and snippets.

@esacteksab
Created January 9, 2014 16:26
Show Gist options
  • Save esacteksab/8337083 to your computer and use it in GitHub Desktop.
Save esacteksab/8337083 to your computer and use it in GitHub Desktop.
import boto
#connect to s3
c = boto.connect_s3()
#get bucket
bucket = c.get_bucket('bucket_name')
#files are keys
bucket.get_all_keys()
#get attributes on a key (file)
keys = bucket.get_all_keys()
#for files in bucket
for key in keys:
print key
print key.last_modified
#get first key -- remove/comment out 'break' below for testing
break
"""
key returned is <class 'boto.s3.key.Key'>
http://boto.readthedocs.org/en/latest/ref/s3.html#module-boto.s3.key
The above will return something like:
<Key: bucket_name,file_name>
2013-12-26T21:26:27.000z
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment