使用php从AWS S3获取私有文件

时间:2016-05-02 14:06:35

标签: php amazon-web-services amazon-s3

我正在尝试从AWS S3获取私有文件但是收到错误

 $client = S3Client::factory([
        'version' => 'latest',
        'region'  => 'us-west-2',
        'signature'    => 'v4',
        'credentials' => [
            'key'    => '****',
            'secret' => '-****'
        ]
    ]);


  $bucket =  'name';
    $file = 'lks/002geH1P1WFXGHWafCwgTw5mwm58X.pdf';
    $url = "{$bucket}/{$file}";

    $request = $client->get($url);
    $signedUrl = $client->createPresignedUrl($request, '+10 minutes');
    echo  $signedUrl;

我收到此错误

  

可捕获的致命错误:参数2传递给   Aws \ AwsClient :: getCommand()必须是类型数组,字符串给定,   在/home/ubuntu/vendor/aws/aws-sdk-php/src/AwsClientTrait.php中调用   在第78行并在中定义   第202行/home/ubuntu/vendor/aws/aws-sdk-php/src/AwsClient.php

1 个答案:

答案 0 :(得分:1)

这有效......希望它能帮助别人;)

class MyClass(protected val someDao: SomeDao)

class TestMyClass extends MyClass(mock[SomeDao]) {
  def someDao2 = someDao
}