S3 list files newer than

别等时光非礼了梦想. 提交于 2021-01-28 01:41:49

问题


We have an S3 bucket, and a directory with all our access logs. I would like to list files newer than a specific time/date. Any way this can be achieved?

The directory has over 100,000 files and it seems inefficient to fetch the entire list and iterate over them all.

Thanks in advance!


回答1:


I don't see any way to do this via the S3 API. You would need to store the file date as part of the S3 object Key, or store a separate index of S3 objects in a database that you could query by date.




回答2:


Okay. Going to make a couple of assumption made on what you've shared so far.
If these are the access files generated by ELB, there is a structure to the format of the name, as documented here http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/access-log-collection.html

If these are not the ELB logs, the way I would solve this is with an S3 Lifecycle Policy, as described here: http://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html
In this case objects older than the duration you set could be expired (i.e. deleted or moved to glacier.



来源:https://stackoverflow.com/questions/32275787/s3-list-files-newer-than

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!