I have a function that adds a file to Digital Ocean Spaces.
Files are Private by default. I want the files to be public for reading.
I added "x-amz-acl": "public-read"
in headers
to get public files.
This solution does not work. The API does not accept and returns the SignatureDoesNotMatch error.
There is nothing in the documentation about this. I perform the action through axios as a pure REST API
const uploadInvitationImage = () => {
axios
.get(general.apiUrl "api/aws/uploadUrl/" name ".png", {
headers: headers,
})
.then((response) => {
if (response.status == 200) {
const uploadUrl = response.data;
axios({
method: "PUT",
url: uploadUrl,
data: fileImage,
headers: {
"Content-Type": "image/png",
"x-amz-acl": "public-read",
},
})
.then((res) => {
setFileImage(null);
})
.catch((err) => {
console.log(err);
});
}
});
};
CodePudding user response:
The API you are calling at "api/aws/uploadUrl/"
needs to add those to the URL it generates, before it signs the URL.