[英]Fetching AWS S3 Object using Presigned URL "SignatureDoesNotMatch"
I created a bucket in the region of Ireland, and blocked all public access on it.我在爱尔兰地区创建了一个存储桶,并阻止了对它的所有公共访问。 Moreover, I created a script to generate a presigned URL to get the object. For some reason, I always get a SignatureDoesNotMatch error.此外,我创建了一个脚本来生成预签名的 URL 以获取 object。出于某种原因,我总是收到 SignatureDoesNotMatch 错误。 I am unable to understand the reason behind it.我无法理解其背后的原因。 below is my code:下面是我的代码:
let getPresignedUrl = async () => {
const AWS = require('aws-sdk');
const s3 = new AWS.S3({apiVersion: '2006-03-01', region: 'eu-west-1'});
console.log(`Starting...`);
const params = {Bucket: 'mybucket', Key: 'potato.jpeg', Expires: 300};
const url = await s3.getSignedUrlPromise('getObject', params);
console.log('The URL is', url); // expires in 60
};
getPresignedUrl();
This is the message I am receiving这是我收到的消息
<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
<AWSAccessKeyId>key</AWSAccessKeyId>
<StringToSign>GET 1603525258 /mybucket/potato.jpeg</StringToSign>
</Error>
Try modifying this:尝试修改这个:
const s3 = new AWS.S3({apiVersion: '2006-03-01', region: 'eu-west-1'});
To this:对此:
const s3 = new AWS.S3({apiVersion: '2006-03-01', region: 'eu-west-1', signatureVersion: 'v4'});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.