amazon web services - AWS SDK for PHP - Fatal Error Issue -


i trying connect s3 upload file via server whenever try run php, encounter following error below. included version , region yet issue still stands?

error:

fatal error: uncaught exception 'invalidargumentexception' message 'missing required client configuration options: region: (string) "region" configuration value required "s3" service (e.g., "us-west-2"). list of available public regions , endpoints can found @ http://docs.aws.amazon.com/general/latest/gr/rande.html. version: (string) "version" configuration value required. specifying version constraint ensures code not affected breaking change made service. example, when using amazon s3, can lock api version "2006-03-01". build of sdk has following version(s) of "s3": * "2006-03-01" may provide "latest" "version" configuration value utilize recent available api version client's api provider can find. note: using 'latest' in production application not recommended. list of available api versions can found on each client's api documentation page: http:/ in /srv/http/auploader/include/aws/clientresolver.php on line 364  

my code:

<?php require '/srv/http/test/include/aws-autoloader.php';  use aws\s3\s3client; use aws\s3\exception\s3exception;  $bucket = 'testbucket'; $keyname = 'sample'; // $filepath should absolute path file on disk                       $filepath = '/srv/http/testfile/setup.html';  // instantiate client. $s3 = s3client::factory(array(     'key'    => 'blank',     'secret' => 'blank' ));  try {     // upload data.     $result = $s3->putobject(array(         'bucket' => $bucket,         'key'    => $keyname,         'sourcefile'   => $filepath,         'acl'    => 'public-read',         'region'  => 'eu-west-1',         'version' => '2006-03-01'     ));        // print url object.     echo $result['objecturl'] . "\n"; } catch (s3exception $e) {     echo $e->getmessage() . "\n"; } ?> 

you have create object of s3. , keys have put misplaced please following.

$s3 = s3client::factory([                 'version'     => 'latest',                 'region'      => 'eu-west-1',                 'credentials' => [                     'key'    => "your s3 bucket key",                     'secret' => "your s3 bucket secret key",                 ]             ]); 

by using s3 object can implement putobject method this.

$result = $s3->putobject(array(             'bucket'     => "yourbucket name",             'key'        => $keyname,             'sourcefile' => $filepath,             'acl'        => 'public-read', //for making public url             'version'    => '2006-03-01' ));         )); 

hope helps!


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -