我们正在尝试使用jQuery ajax和预先签名的URL将文件上传到S3.我们在服务器上生成预先指定的URL.目前我们正在尝试使用FormData上传文件.
var uploadData = new FormData(),
files = $(this.input).prop('files'),
file = files[0];
uploadData.append('file', file);
$.ajax({
url: '{presigned url string}',
type: 'PUT',
data: uploadData,
cache: false,
processData: false,
contentType: false,
success: function(response) {
console.log('S3 upload success!');
},
error: function(response) {
console.log('Error with S3 upload: ' + response.statusText);
}
});
Run Code Online (Sandbox Code Playgroud)
这将从AWS返回SignatureDoesNotMatch错误:
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we
calculated does not match the signature you provided. Check your key and
signing method.</Message><StringToSignBytes>50 55 54 0a 0a 6d 75 6c 74 69 70 …Run Code Online (Sandbox Code Playgroud)