简体   繁体   中英

Is there a way to list all files in a S3 bucket between two dates?

I am trying to fetch all files between two given dates using the S3 API called s3ap but I am not getting correct syntax for the same.

When I tried for all files after a given date I am able to do that by using below mentioned command:

aws s3api list-objects --profile flashtalking --bucket bucket-name --query "Contents[?LastModified >= '$last_modificaion_date']"

I modified the above query slightly and I was able to get it working.

Hope this helps!

ubuntu@ip-172-31-19-128:~$ aws s3api list-objects --bucket s3-knowledge-base --query 'Contents[?LastModified>=`2019-05-21T14:38:07.000Z`].{Key : Key, LastModified: LastModified }'

[
    {
        "Key": "images/tnats/connectivity.JPG",
        "LastModified": "2019-05-21T14:38:07.000Z"
    },
    {
        "Key": "images/tnats/gsk-logo.png",
        "LastModified": "2019-05-29T16:58:46.000Z"
    }
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM