How to make object public on upload(using aws-sdk js)

Hi all, I’m trying to upload files via aws-sdk. How can I make the object public upon upload?

Here’s my code. This was working perfectly before(I was using digital ocean spaces) but now it doesn’t work. Issue seems to be with Cloudflare not recognizing public-read acl.

const params = {
          Bucket: "my-bucket", 
          Key: fileName,
          Body: data,
          ACL: "public-read",
          ContentType: "image/png",
        };
       s3.upload(params, function (s3Err, data) {
          if (s3Err) throw s3Err;
          console.log(`File uploaded successfully at ${data.Location}`);
          resolve(data.Location);
        });

Has anybody solved this? Seems to be fairly common scenario to upload publicly accessible files.

Thanks.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.