My project is:
-
List my buckets
-
List the objects in each bucket
I created a foreach to list the buckets and it worked perfectly.
The same thing happened with the foreach of objects.
$buckets = $s3->getIterator('ListBuckets', []);
foreach($buckets as $bucket) {
$objects = $s3->getIterator('ListObjects', [ 'Bucket' => $bucket ]);
foreach($objects as $object) {
// não retornou nada e ainda deu erro
}
}
Page Fault Displays:
Fatal error: Uncaught InvalidArgumentException: Found 1 error while validating the input provided for the ListObjects operation: [Bucket] must be a string or an object that implements __toString(). Found array(2) in C:\xampp\htdocs\backup\vendor\aws\aws-sdk-php\src\Api\Validator.php:65 Stack trace: #0 C:\xampp\htdocs\backup\vendor\aws\aws-sdk-php\src\Middleware.php(79): Aws\Api\Validator->validate('ListObjects', Object(Aws\Api\StructureShape), Array) #1 C:\xampp\htdocs\backup\vendor\aws\aws-sdk-php\src\S3\S3Client.php(405): Aws\Middleware::Aws\{closure}(Object(Aws\Command), NULL) #2 C:\xampp\htdocs\backup\vendor\aws\aws-sdk-php\src\S3\S3Client.php(428): Aws\S3\S3Client::Aws\S3\{closure}(Object(Aws\Command), NULL) #3 C:\xampp\htdocs\backup\vendor\aws\aws-sdk-php\src\S3\S3Client.php(362): Aws\S3\S3Client::Aws\S3\{closure}(Object(Aws\Command), NULL) #4 C:\xampp\htdocs\backup\vendor\aws\aws-sdk-php\src\S3\S3Client.php(381): Aws\S3\S3Client::Aws\S3\{closure}(Object(Aws\Command), NULL) #5 C:\xampp\htdocs\backup\vendor\aws\aws-s in C:\xampp\htdocs\backup\vendor\aws\aws-sdk-php\src\Api\Validator.php on line 65
Would anyone know how to make this object listing within the buckets work?
Any help is welcome!