php - Amazon s3 batch upload -


i have been trying batch upload using s3 client execute() method. keeps throwing exception:

message: argument 1 passed aws\awsclient::execute() must implement interface aws\commandinterface, array given, called in....

even after following example code doc.

check example maybe doing wrong:

$bucket   = 'mybucket'; $commands = [];  $s3 = new aws\s3\s3client([     'version' => 'latest',     'region'  => 'us-west-1', ]);  $commands[] = $s3->getcommand('putobject', [     'bucket' => $bucket,     'key'    => 'key1.gif',     'body'   => 'path_to_file_1', ]);  $commands[] = $s3->getcommand('putobject', [     'bucket' => $bucket,     'key'    => 'key2.gif',     'body'   => 'path_to_file_2', ]);  $s3->execute($commands); 

thanks in advance!

just solved myself.

instead of calling $s3->execute(), pass client , $commands array commandpool so:

use aws\commandpool;  // code here  $results = commandpool::batch($s3, $commands); 

you'll receive array of results, sorted in same order commands. 1 of differeneces include exception objects if command failed.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -