Aws-cli: Sort Objects In Amazon S3 by last Date

Created on 10 Aug 2016  路  1Comment  路  Source: aws/aws-cli

I use Amazon to upload object and S3bubble plugin to display video. They're sorted alphabetically by key In Amazon S3.

How to solve this problem. Please help me

guidance service-api

Most helpful comment

There is not really a way to do this server side. I would recommend asking the forums for this feature request: https://forums.aws.amazon.com/forum.jspa?forumID=24

The best you can do is use client-side filtering that the CLI provides with --query.

So to list from oldest to latest, you can do:

aws s3api list-objects --bucket mybucketfoo --query "sort_by(Contents,&LastModified)"

Or if you want to do in the reverse order do:

aws s3api list-objects --bucket mybucketfoo --query "reverse(sort_by(Contents,&LastModified))"

If you have any further questions, lets move the conversation onto gitter

>All comments

There is not really a way to do this server side. I would recommend asking the forums for this feature request: https://forums.aws.amazon.com/forum.jspa?forumID=24

The best you can do is use client-side filtering that the CLI provides with --query.

So to list from oldest to latest, you can do:

aws s3api list-objects --bucket mybucketfoo --query "sort_by(Contents,&LastModified)"

Or if you want to do in the reverse order do:

aws s3api list-objects --bucket mybucketfoo --query "reverse(sort_by(Contents,&LastModified))"

If you have any further questions, lets move the conversation onto gitter

Was this page helpful?
0 / 5 - 0 ratings