Report this

What is the reason for this report?

Unable to upload images into spaces in angular

Posted on January 20, 2020

When i try to upload images into spaces i am getting 403 forbidden issue and cors issue.

s3 = new AWS.S3({
    endpoint: endPoint,
    accessKeyId: accessKey,
    secretAccessKey: secretKey
  });

 const params = {
        Bucket: 'test-upload',
        Key: file.name,
        Body: file,
        ContentType: file[0].type,
        ACL: 'public-read',
        // CORSConfiguration: { CORSRules: this.corsRules }
        // headers: { 'Access-Control-Allow-Origin': '*' }
      };
      this.s3.putObject(params, (err, data) => {
        if (err) {
          console.log('err', err);
        } else {
          console.log('Successfully uploaded data to DO speaces', data);
        }
      });


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!

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.

Hello,

I believe that you have to try to add your domain name the CORS Configurations under your DigitalOcean Control panel:

  • Go to your DigitalOcean Control Panel
  • Then go to Space
  • Select your Space
  • Click on Settings
  • Under the CORS Configurations add your domain name and select GET.

Hope that this helps! Regards, Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.