无法从对象URL访问文件
问题描述:
我无法访问该文件,我尝试通过预先签名的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();
当网址在浏览器来访问我得到:
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');
我仍然收到相同的错误。
这里是斗许可快照:
答
你检查你CORS配置?
https://aws.amazon.com/blogs/aws/amazon-s3-cross-origin-resource-sharing/
在一个共同的CORS配置,可以允许起源,方法和头。我将从添加CORS配置开始。
看起来你的客户端不支持必要的加密算法。 –
@GeraldSchneider对不起,这是什么意思? –
我没有使用AWS的经验,所以这只是一个猜测。但服务器正在抱怨你的客户端不支持'AWS4-HMAC-SHA256',这是加密算法中常见部分的一种亚马逊变体。您的客户端不支持它(可能已过时),或者它配置错误。 –