How list Amazon S3 bucket contents by modified date?

后端 未结 8 1274
[愿得一人]
[愿得一人] 2020-12-14 06:30

Most of the time it happens that we load files in a common S3 bucket due to which it becomes hard to figure out data in it.

How can I view objects uploaded on a part

相关标签:
8条回答
  • 2020-12-14 06:58

    This isn't a general solution, but can be helpful where your objects are named based on date - such as CloudTrail logs. For example, I wanted a list of objects created in June 2019.

    aws s3api list-objects-v2 --bucket bucketname --prefix path/2019-06
    

    This does the filtering on the server side. The downside of using the "query" parameter is it downloads a lot of data to filter on the client side. This means potentially a lot of API calls, which cost money, and additional data egress from AWS that you pay for.

    Source: https://github.com/aws/aws-sdk-js/issues/2543

    0 讨论(0)
  • 2020-12-14 07:02

    Search on a given date

    aws s3api list-objects-v2 --bucket BUCKET_NAME --query 'Contents[?contains(LastModified, `YYYY-MM-DD`)].Key'
    

    Search from a certain date to today

    aws s3api list-objects-v2 --bucket BUCKET_NAME  --query 'Contents[?LastModified>=`YYYY-MM-DD`].Key'
    

    You can optionally remove the .Key from the end of the query to grab all metadata fields from the s3 objects

    0 讨论(0)
提交回复
热议问题