Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

512
Views
AWS SDK for PHP - Fatal Error Issue

I am trying to connect to my S3 to upload a file via my server but whenever i try to run the PHP, i encounter the following error below. I included the Version and Region but yet the issue still stands?

Error:

Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Missing required client configuration options: region: (string) A "region" configuration value is required for the "s3" service (e.g., "us-west-2"). A list of available public regions and endpoints can be found at http://docs.aws.amazon.com/general/latest/gr/rande.html. version: (string) A "version" configuration value is required. Specifying a version constraint ensures that your code will not be affected by a breaking change made to the service. For example, when using Amazon S3, you can lock your API version to "2006-03-01". Your build of the SDK has the following version(s) of "s3": * "2006-03-01" You may provide "latest" to the "version" configuration value to utilize the most recent available API version that your client's API provider can find. Note: Using 'latest' in a production application is not recommended. A list of available API versions can be 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 be absolute path to a file on disk                      
$filepath = '/srv/http/testfile/setup.html';

// Instantiate the 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 the URL to the object.
    echo $result['ObjectURL'] . "\n";
} catch (S3Exception $e) {
    echo $e->getMessage() . "\n";
}
?>
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You have to create an object of S3. And keys you have put is misplaced please do it as 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 you can implement putObject method something like this.

$result = $s3->putObject(array(
            'Bucket'     => "yourbucket name",
            'Key'        => $keyName,
            'SourceFile' => $filepath,
            'ACL'        => 'public-read', //for making the public url
            'Version'    => '2006-03-01'
));
        ));

Hope it helps!

about 4 years ago · Santiago Trujillo Report

0

For SES AWS SDK v3 use

/*
* 1. version as `2010-12-01`
* 2. version as Eg. `us-east-1`.
*/
ini_set("display_errors", 1);
Aws\Ses\SesClient::factory(array(
        'credentials' => array(
            'key' => "someKey",
            'secret' => "someSecret",
        ),
        "region" => "us-east-1",
        "version" => "2010-12-01")
);
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!