我怎样才能从亚马逊s3获得免费访问的图片?

时间:2018-05-01 09:07:22

标签: php amazon-s3

我拥有可以完全访问Bucket的亚马逊帐户 和下一个请求:

        $credentials = new Credentials('*****', '***');
        $sts = StsClient::factory([
            'version' => 'latest',
            'region' => '*****',
            'credentials' => $credentials
        ]);

        $credentials = $sts->getSessionToken()->get('Credentials');

        $s3Client = new Aws\S3\S3Client([
            'version' => 'latest',
            'region'  => '*******',
            'credentials' => $credentials
        ]);

        $cmd = $s3Client->getCommand('GetObject', [
            'Bucket' => '******',
            'Key' =>  $src,
            'SSECustomerAlgorithm' => 'AWS4-HMAC-SHA256',
            'x-amz-server-side-encryption' => 'AES256',
        ]);

        $request = $s3Client->createPresignedRequest($cmd, '+20 minutes');
        $presignedUrl = (string) $request->getUri();

但我总是得到下一个错误

  

无效令牌

0 个答案:

没有答案