简体   繁体   中英

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();
}

尝试使用ap-southeast-1作为区域,而不是s3-ap-southest-1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM