Я столкнулся с проблемой, из-за которой подпись не соответствует ошибке при загрузке моего изображения.Ищите всех, чтобы взглянуть на мой код, есть ли какое-либо решение, чтобы исправить это.
// image is filePath like file://data/storage/0/...jpg
export const uploadImageToS3 = async (image, signS3, mime) => {
let file = {
uri: image,
type: "image/png"
};
const data = await uploadFile(file, signS3.uploadUrl, mime,);
return data;
};
const uploadFile = (file, signedRequest, mime) => {
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
console.log("Image successfully uploaded to S3");
console.log(xhr);
} else {
console.log("Error while sending the image to S3");
console.log(xhr);
}
}
console.log(xhr);
};
xhr.open("PUT", signedRequest);
xhr.setRequestHeader("X-Amz-ACL", "public-read");
xhr.setRequestHeader("Content-Type", mime);
xhr.send(file);
};
Ниже приведено сообщение об ошибке:
<Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
Я попробовал setHeader Content-type, x-amz-acl, но он все еще показывает ошибку.А ответ пустой представляет собой то, что после успешной отправки