无法将文件上传到Amazon S3

时间:2018-03-12 02:45:20

标签: php amazon-s3

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

  

"执行错误" PutObject"上   " https://bucketname.s3.s3-ap-southeast-1.amazonaws.com/WIN_20171117_16_45_59_Pro.jpg&#34 ;;   AWS HTTP错误:cURL错误51:SSL:没有替代证书主题   name匹配目标主机名   ' 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();
}

1 个答案:

答案 0 :(得分:2)

尝试使用scala> val a = Set(Array(1, 2),Array(8, 9)) a: scala.collection.immutable.Set[Array[Int]] = Set(Array(1, 2), Array(8, 9)) scala> a.flatMap(_) <console>:9: error: missing parameter type for expanded function ((x$1) => a.flatMap(x$1)) a.flatMap(_) ^ scala> a.flatMap(x=>x) res4: scala.collection.immutable.Set[Int] = Set(1, 2, 8, 9) 作为区域,而不是x=>x