dongqinta4174 2015-09-23 13:07
浏览 119
已采纳

php中的亚马逊s3配置

I have following Amazon s3 configuration:

   $Connection = new S3Client(array(
        'version'  => 'latest',
        'region'   => 'custom-region',
        'endpoint' => 'http://mydomine.com',
        'credentials' => [
            'key'    => AWS_KEY,
            'secret' => AWS_SECRET_KEY,
           // 'token' => false,
            //'canonical_id' => AWS_CANONICAL_ID,
           // 'canonical_name' => AWS_CANONICAL_NAME,
        ]
    ));

But calling this:

print_r($Connection->listBuckets());

I got:

PHP Fatal error: Uncaught exception 'Aws\S3\Exception\S3Exception' with message 'Error executing "ListBuckets" on "http://mydomine.com"; AWS HTTP error: Client error: 400 InvalidArgument (client): - InvalidArgument'

exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: 400' in /home/kristineg/public_html/ocr/scanning/vendor/guzzlehttp/guzzle/src/Middleware.php:69 Stack trace: 0 /home/kristineg/public_html/ocr/scanning/vendor/guzzlehttp/promises/src/Promise.php(199): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response)) 1 /home/kristineg/public_html/ocr/scanning/vendor/guzzlehttp/promises/src/Promise.php(152): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) 2 /home/kristineg/public_html/ocr/scanning/vendor/guzzlehttp/promises/src/TaskQueue.php(60): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}() 3 /home/kristineg/public_html/ocr/scanning/vendor/guzzlehttp/gu in /home/kristineg/public_html/ocr/scanning/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php on line 152

As I understand, client is not configured correctly, but I can't imagine what exactly :(

Maybe somebody has any idea?

p.s. installed via composer like:

{
    "require": {
        "aws/aws-sdk-php": "^3.3",
        "doctrine/cache": "^1.4",
        "aws/aws-sdk-php-resources": "^0.3.0"
    }
}
  • 写回答

1条回答 默认 最新

  • dongzhong5833 2015-09-24 08:50
    关注

    I'll go with older version, here I don't need to specify region. :)

    $client = S3Client::factory([
            'key'    => Yii::$app->params['amazonS3']['accessKey'],
            'secret' => Yii::$app->params['amazonS3']['secretKey'],
            'base_url' => Yii::$app->params['amazonS3']['endpoint'],
        ]);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?