Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to set ACL to public-read when adding a file to S3 or DigitalOcean

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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);
            });
        }
      });
  };

>Solution :

The API you are calling at "api/aws/uploadUrl/" needs to add those to the URL it generates, before it signs the URL.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading