I am trying to get the list of Object
under a specific folder in my bucket.
I know that to get a list of all of my objects I do:
$objects = $client->getIterator('ListObjects', array( 'Bucket' => $bucket ));
I want to get only the objects under the folder my/folder/test
. I have tried adding
'key' => "my/folder/test",
And
'prefix' => "my/folder/test",
But it simply returns all of the objects in my bucket.
You need to use Prefix
to restrict the search to a specific directory (a common prefix).
$objects = $client->getIterator('ListObjects', array( "Bucket" => $bucket, "Prefix" => "your-folder/" ));
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