I am using the Amazon S3 SDK for PHP. I am wondering if there is a way to retrieve the objects in a particular order, like by file name, or by modified date. Currently it is just listing them based on when they were uploaded. I am using this method, but maybe there is another method that would fit better.
$object_list_array = $s3->get_object_list(MYBUCKET, array(
'prefix' => '/path/to/folder/with/files/'
));
What is the best way to express what order I would like them returned?
I don't think it's possible. If you check the definition of the get_object_list function in
sdk/services/s3.class.php
it lists a load of options which can be passed, but there's a notable lack of an option to define the order of the results:
In my limited testing it seems to return the files ordered by their name rather than their creation date.
Not using the SDK directly. However, there are alternative options. For example, if you were to store your objects in an array, you can take advantage of PHP's numerous array-sorting methods.