无法从对象URL访问该文件

时间:2016-01-20 12:26:25

标签: php amazon-web-services amazon-s3 pre-signed-url

我无法访问该文件,我试图通过预先签名的URL访问该文件。

    $cmd = $s3Client->getCommand('GetObject', [
            'Bucket' => 'test-bucket-pcloud',
            'Key'    => 'testfile.txt'
    ]);

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

    // Get the actual presigned-url
    $presignedUrl = (string) $request->getUri();

在浏览器上访问URL时,我得到:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
    <Error>
    <Code>AuthorizationQueryParametersError</Code>
    <Message>X-Amz-Algorithm only supports "AWS4-HMAC-SHA256"</Message>
    <RequestId>8D109D39C69E665D</RequestId>
    <HostId>
    lH+u+MEnbF+Sps0kd/tMEGS0ePHjQlUDGWN8lLnzkXYkrIb0YksK6ahzUflPFMbQG8zUzLFl9y4=
    </HostId>
    </Error>

它可能是什么原因?此外,当我尝试从获取的URL访问存储桶时:

$signedURL = $s3Client->getObjectUrl('test-bucket-pcloud','testfile.txt');

我仍然得到同样的错误。

以下是存储桶的权限快照:

enter image description here

1 个答案:

答案 0 :(得分:0)

您是否检查过CORS配置?

https://aws.amazon.com/blogs/aws/amazon-s3-cross-origin-resource-sharing/

在常见的CORS配置中,您可以允许原点,方法和标题。我将首先添加一个CORS配置。