簡體   English   中英

無法將文件上傳到Amazon S3

[英]Can't Upload File to Amazon S3

嘗試將對象上傳到亞馬遜s3存儲桶時遇到問題。 它始終顯示錯誤,並且網址上帶有s3。

“在“ 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 )”

這是我將圖片上傳到亞馬遜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