为什么我会从SignatureDoesNotMatch亚马逊预先签名的Url请求中得到一个S3错误?
我正在使用AWS生成签名的putObject url,并使用jQuery来发布Ajax请求,使用Dropzone.js来管理文件上传。
上传与curl -v -T <IMAGE> <PRE-SIGNED-URL>一起工作。
请求:
// Send uploads to s3 signed urls.
// @param res [Object] of signed-url's for image files.
function sendFiles(res){
res.forEach(function(signedUrl){
// Get file for associated Dropzone queued file.
var file = returnFile(signedUrl.options.id);
// signedUrl.url returns:
// https://bucket.s3-us-west-1.amazonaws.com/path/(key:filename)Type=image%2Fjpeg&Expires=1449874843&Signature=####&x-amz-acl=public-read-write`
$.ajax({
url: signedUrl.url,
type: 'PUT',
data: file.upload,
contentType:'multipart/form',
dataType: 'json',
complete:function(data){
console.log("Done", data);
},
error:function(data){
console.log("Error", data);
}
});
});
}响应:
<Code>
SignatureDoesNotMatch
</Code>
<Message>
The request signature we calculated does not match the signature you provided.
Check your key and signing method.
</Message>发布于 2015-12-12 05:37:33
,我找到了一个解决方案,,这做了两次修改。我希望有人能更好地解释他们。
第一
我必须在aws返回的decodeURIComponent()签名的url字符串上运行s3。
第二
我必须更改三个选项,并向ajax请求添加两个新选项。
{
data: file,
contentType:'image/jpeg',
dataType:"text",
cache : false,
processData : false
}https://stackoverflow.com/questions/34234900
复制相似问题