2017-06-23 40 views

回答

0

S3没有列出按日期排列的文件的API 但是,如果确实只有少数几个,则可以列出存储区中的文件并按上次修改时间排序。

bucketList = s3Client.list_objects(Bucket=<MyBucket>) # notice this is up to 1000 files 
orderedList = sorted(bucketList, key=lambda k: k.last_modified) 
lastUpdatedKey = orderedList[-1] 
object = s3Client.get_object(Bucket=<MyBucket>, Key=lastUpdatedKey) 
+0

注意我在https://stackoverflow.com/questions/7969653/s3-boto-list-files-within-a-bucket-by-upload-time中引用了答案。 –