【问题标题】:Can't Upload File to Amazon S3无法将文件上传到 Amazon S3
【发布时间】:2018-08-20 00:21:30
【问题描述】:

我在尝试将对象上传到我的 amazon s3 存储桶时遇到问题。它总是显示错误,并且在 url 上有 s3。

“执行“PutObject”时出错 "https://bucketname.s3.s3-ap-southeast-1.amazonaws.com/WIN_20171117_16_45_59_Pro.jpg"; AWS HTTP 错误:cURL 错误 51:SSL:没有替代证书主题 name 匹配目标主机名 'bucketname.s3.s3-ap-southeast-1.amazonaws.com'(见 http://curl.haxx.se/libcurl/c/libcurl-errors.html)"

这是我将图像上传到 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();
}

【问题讨论】:

  • 旁注:现在,使用减少冗余已经不是特别值得了。在新加坡地区,它的收费为 2.4c/GB,而标准存储为 2.5c/GB。在某些地区,它实际上是贵!

标签: php amazon-s3


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2021-05-21
    • 2014-12-16
    • 2018-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-10
    • 2013-09-09
    • 2015-10-28
    相关资源
    最近更新 更多