I'm trying to get the last object in a bucket order by last modified using AWS SDK for PHP version 3.x.
I have seen how to doit with the AWS CLI. Here:
But I can't see how to do it with PHP SDK.
$S3Client = new Aws\S3\S3Client([
'version' => 'latest',
'region' => 'eu-west-3',
'credentials' => [
'key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
]
]);
$startTime = strtotime('-5 minutes');
$res = $S3Client->ListObjectsV2([
'Bucket' => 'my-bucket',
'Prefix' => 'objects/',
'StartAfter' => $startTime
])
I'm using ListObjectsV2 method which is the recommended one.
I have three problems.
How may I order the result by LastModify? (As is posible to do with CLI)
I have some lifecycle policies and this affects to my search because I get some results of objects moving to GLACIER STORAGE which I do not want.
I want the tags a metadata of the object. How can I get it?. Is using x-amz-optional-object-attributes? How?
By the way, using StartAfter parameter does not seems to change anything