Currently when i call $s3->list_objects()
method it return me objects in the order those objects were added. I want to list object in reverse order so that i can have newest objects first. I cannot find any parameter that i can pass to the $s3->list_objects()
method that can reverse the order. I am using Amazon S3 PHP SDK. Is there is any such parameter or method?
Returns some or all (up to 1,000) of the objects in a bucket. You can use the request parameters as selection criteria to return a subset of the objects in a bucket. A 200 OK response can contain valid or invalid XML.
Retrieves objects from Amazon S3. To use GET , you must have READ access to the object. If you grant READ access to the anonymous user, you can return the object without using an authorization header.
A delete marker in Amazon S3 is a placeholder (or marker) for a versioned object that was named in a simple DELETE request. Because the object is in a versioning-enabled bucket, the object is not deleted.
I'm looking to do the same thing and I really don't feel like I want a DB in the way to keep track of the latest objects. Since you just need them to have alphabetically reverse order keys.
A timestamp is alphabetical in ordering usually. A timestamp can be represented as a long. We can get a reverse alphabetical time identifier by taking the (max long - timestamp long) and formatting that with all leading 0s.
So if you store your S3 Objects with the key = prefix + timestampId + postfix you can use list to get the newest objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With