简体   繁体   English

无法将文件上传到Amazon S3

[英]Can't Upload File to Amazon S3

I have a problem when I trying uploading objects to my amazon s3 bucket. 尝试将对象上传到亚马逊s3存储桶时遇到问题。 It always shows error and it has s3 on the url. 它始终显示错误,并且网址上带有s3。

"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 )" “在“ https://bucketname.s3.s3-ap-southeast-1.amazonaws.com/WIN_20171117_16_45_59_Pro.jpg ”上执行“ PutObject”时发生错误; AWS HTTP错误:cURL错误51:SSL:没有其他证书主题名称与目标匹配主机名'bucketname.s3.s3-ap-southeast-1.amazonaws.com”(请参见http://curl.haxx.se/libcurl/c/libcurl-errors.html )”

Here's my code for uploading images to the amazon s3 这是我将图片上传到亚马逊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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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