amazon web services - python boto for aws s3, how to get sorted and limited files list in bucket? -
if there many files on bucket, , want 100 newest files, how can these list?
s3.bucket.list seems not have function. there know this?
please allow me know. thanks.
there no way type of filtering on service side. s3 api not back upwards it. might able accomplish using prefixes in object names. example, if named of objects using pattern this:
yyyymmdd/<objectname> 20140618/foobar (as example) you utilize prefix parameter of listbucket request in s3 homecoming object stored today. in boto, like:
import boto s3 = boto.connect_s3() bucket = s3.get_bucket('mybucket') key in bucket.list(prefix='20140618'): # key object you still have retrieve of objects prefix , sort them locally based on last_modified_date much easier listing of objects in bucket , sorting.
the other alternative store metadata object s3 objects in database dynamodb , query database find objects retrieve s3.
you can find out more hierarchical listing in s3 here
amazon-web-services amazon-s3 boto
No comments:
Post a Comment