Node.js 403响应-s3预签名
我正在Heroku服务器上运行一个应用程序,并试图使用预签名上传到S3。我得到了signedurl,但当我用它上传文件时,我只得到了403响应。我在某个地方看到我的签名版本可能不正确,但我还没有找到解决方案。我将在下面附上我的源代码。 客户端上传代码Node.js 403响应-s3预签名,node.js,amazon-s3,file-upload,http-status-code-403,pre-signed-url,Node.js,Amazon S3,File Upload,Http Status Code 403,Pre Signed Url,我正在Heroku服务器上运行一个应用程序,并试图使用预签名上传到S3。我得到了signedurl,但当我用它上传文件时,我只得到了403响应。我在某个地方看到我的签名版本可能不正确,但我还没有找到解决方案。我将在下面附上我的源代码。 客户端上传代码 getSignedRequest(file){ var that = this const xhr = new XMLHttpRequest(); xhr.open('GET', `/sign-s3?fil
getSignedRequest(file){
var that = this
const xhr = new XMLHttpRequest();
xhr.open('GET', `/sign-s3?file-name=${encodeURIComponent(file.name)}&file-type=${encodeURIComponent(file.type)}`);
xhr.onreadystatechange = () => {
if(xhr.readyState === 4){
if(xhr.status === 200){
const response = JSON.parse(xhr.responseText);
that.uploadFile(file, response.signedRequest, response.url);
}
else{
alert('Could not get signed URL.');
}
}
};
xhr.send();
}
uploadFile(file, signedRequest, url){
const xhr = new XMLHttpRequest();
xhr.open('PUT', signedRequest);
xhr.onreadystatechange = () => {
console.log()
if(xhr.readyState === 4){
if(xhr.status === 200){
alert('yay')
}
else{
alert('Could not upload file.');
}
}
};
xhr.send(file);
}