If you are using a modern version of the SDK, try creating the command this way. Taken straight from the docs ; he should work. This is called the chaining method.
$commands = array(); $commands[] = $s3->getCommand('PutObject') ->set('Bucket', $bucket) ->set('Key', 'images/1.jpg') ->set('Body', base64_decode('xxx')) ->set('ACL', 'public-read') ->set('ContentType', 'image/jpeg'); $commands[] = $s3->getCommand('PutObject') ->set('Bucket', $bucket) ->set('Key', 'images/2.jpg') ->set('Body', base64_decode('xxx')) ->set('ACL', 'public-read') ->set('ContentType', 'image/jpeg'); // Execute the commands in parallel $s3->execute($commands); // Loop over the commands, which have now all been executed foreach ($commands as $command) { $result = $command->getResult(); // Use the result. }
Make sure you are using the latest SDK.
Edit
It looks like the SDK API has changed significantly in version 3.x. The above example should work correctly in version 2.x of the AWS SDK. For 3.x you need to use CommandPool() and promise() :
$commands = array(); $commands[] = $s3->getCommand('PutObject', array( 'Bucket' => $bucket, 'Key' => 'images/1.jpg', 'Body' => base64_decode ( 'xxx' ), 'ACL' => 'public-read', 'ContentType' => 'image/jpeg' )); $commands[] = $s3->getCommand('PutObject', array( 'Bucket' => $bucket, 'Key' => 'images/2.jpg', 'Body' => base64_decode ( 'xxx' ), 'ACL' => 'public-read', 'ContentType' => 'image/jpeg' )); $pool = new CommandPool($s3, $commands);
Then $result should be an array of command results.
source share