【发布时间】: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。在某些地区,它实际上是更贵!