问题
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