0

Im trying to upload a photo to my bucket. I already generate a STS accesskey and secreykey and session token using boto3.

AWS.config.update({ accessKeyId: aws_cred.access_key, secretAccessKey: aws_cred.secret_key, sessionToken: aws_cred.session_token });

var unique_key = "files101/" + file.name;

var params = { Key: unique_key, ContentType: file.type, Body: file, ACL: 'public-read' };

bucket.upload(params, opts, function(err, data) {
    if(err) {
              console.log(err);
              return 0;
            }
});

I got still got this error

 No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9999' is therefore not allowed access.

even if I already added ACL to my bucket

enter image description here

I have this CORS

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
    <AllowedMethod>PUT</AllowedMethod>
    <AllowedMethod>POST</AllowedMethod>
    <AllowedMethod>DELETE</AllowedMethod>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
    <ExposeHeader>x-amz-meta-custom-header</ExposeHeader>
    <ExposeHeader>ETag</ExposeHeader>
    <AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>

Anyone can help me?. thanks

ParTidA
  • 106
  • 1
  • 7

1 Answers1

0

This error usually fix when you add CORS configuration into your bucket. Here is a good answer with some other workarounds.

https://stackoverflow.com/a/19939041/5358917

Kavindra
  • 1,697
  • 2
  • 14
  • 19
  • Im not sure if this error is about my CORS. My upload works fine when using my actual keys not the STS generated keys. – ParTidA Jul 20 '17 at 07:08