Upload AWS S3 getSignedUrl with correct permissions and Content Type

Hi there,

I am trying to upload assets through the getSignedUrl method that the aws-sdk provides, a NodeJS backend with Axios where the upload happens from a VueJS 2 frontend. Now whatever combination i try, or the file is able to upload but always sets it to private and the wrong Content-Type, or i get 403 permission errors.

What i want to do is that the upload has an ACL that is public-read and the correct Content-Type.

The following is the code that i use:

To get a signed Url

const s3 = new AWS.S3({
    accessKeyId: keys.spacesAccessKeyId,
    secretAccessKey: keys.spacesSecretAccessKey,
    signatureVersion: 'v4',
    endpoint: '',
    region: 'fra1'

app.get('/api/upload/image', (req, res) => {
        const type = req.query.type;

        s3.getSignedUrl('putObject', {
            Bucket: 'vondel',
            ContentType: type,
            ACL: 'public-read',
            Key: 'random-key'
        }, (error, url) => {
            if (error) {
            console.log('KEY:', key);
            console.log('URL:', url);
            res.send({ key, url });

This provides a signed url that looks like:

Then for actually uploading the file i use the following:

await UploadService.uploadImage(, file, {
          'x-amz-acl': 'public-read',
          'Content-Type': file.type

With the service looking like:

  async uploadImage (url, file, headers) {
    await axios.put(url, file, headers.headers);
Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

What i had to do to fix this issue, was going to the Settings page of my Spaces instance and add to the CORS section the following allowed Headers (i had previously set the Origin to be a wildcard as i am working from localhost, eventually you want to restrict this to a domain).

But add the allowed headers ‘Content-Type’ and ‘x-amz-acl’ to properly set the content type and the ACL.

This way i was able to upload an image to my DigitalOcean spaces with public permission and the right content type.

In my case, I needed to add all of the AWS headers, along with some common headers:

Common headers:


Amazon headers:


If you are applying a CORS policy to a specific domain that you trust, I’d consider just allowing all headers using a wildcard *.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel