我有一个使用Node和AWS-SDK包的应用程序。我使用copyObject方法将对象从一个桶复制到另一个桶。我收到的错误是SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your key and signing method.
我已经能够在本地计算机上成功运行代码,并将文件从一个存储桶复制到另一个存储桶。我在部署应用程序的AWS服务器上发生错误。完整的错误是:
{ [SignatureDoesNotMatch: The request signature we calculated does not
match the signature you provided. Check your key and signing method.]
message: 'The request signature we calculated does not match the signature you provided. Check your key and signing method.',
code: 'SignatureDoesNotMatch',
region: null,
time: Mon Jul 11 2016 12:11:36 GMT-0400 (EDT),
requestId: <requestId>,
extendedRequestId: <extendedRequestId>,
cfId: undefined,
statusCode: 403,
retryable: false,
retryDelay: 66.48076744750142 }
此外,我能够执行listObjects
命令。该错误仅发生在copyObject
上。
到目前为止,我已经尝试了
correctClockSkew
设为true 以下是导致问题的代码:
AWS.config.update({
accessKeyId: <accessKeyId>,
secretAccessKey: <secretAccessKey>,
correctClockSkew: true
});
var s3 = new AWS.S3();
var params = {
Bucket: <bucket>,
Prefix: <prefix>
};
s3.listObjects(params, function(err, data) {
if (data.Contents.length) {
async.each(data.Contents, function(file, cb) {
var file_name = file.Key.substr(file.Key.indexOf('/')+1);
var copy_params = {
Bucket: <bucket2>,
CopySource: <bucket> + '/' + file.Key,
Key: file_name,
ACL: 'public-read'
};
s3.copyObject(copy_params, function(copyErr, copyData){
if (copyErr) {
console.log('Error:', copyErr);
}
else {
cb();
}
});
}, function(err){
...
}
});
} else {
...
}
});