P. James
P. James

Reputation: 435

Can't Upload File to Amazon S3

I have a problem when I trying uploading objects to my amazon s3 bucket. It always shows error and it has s3 on the url.

"Error executing "PutObject" on "https://bucketname.s3.s3-ap-southeast-1.amazonaws.com/WIN_20171117_16_45_59_Pro.jpg"; AWS HTTP error: cURL error 51: SSL: no alternative certificate subject name matches target host name 'bucketname.s3.s3-ap-southeast-1.amazonaws.com' (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)"

Here's my code for uploading images to the amazon s3

require "aws/aws-autoloader.php";
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;

$client = S3Client::factory(
    array(
      'credentials' => array(
        'key' => $key,
        'secret' => $secret
      ),
      'version' => 'latest',
      'region'  => 's3-ap-southeast-1'
    )
  );

try {
  $client->putObject(array(
    'Bucket'=>$bucket,
    'Key' =>  $keyname,
    'SourceFile' => $sourcefile, 
    'StorageClass' => 'REDUCED_REDUNDANCY',
    'ContentType' => 'image',
    'ACL' => 'public-read'
  ));

} catch (S3Exception $e) {
  // Catch an S3 specific exception.
  echo $e->getMessage();
}

Upvotes: 1

Views: 1895

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269091

Try using ap-southeast-1 as the region instead of s3-ap-southest-1.

Upvotes: 2

Related Questions