0
votes

The issue is related to S3 bucket CORS. I randomly receive the following error in the browser's console (sometimes, mostly not) :

"No 'Access-Control-Allow-Origin' header is present on the requested resource"

I have checked that CORS is well enabled via aws cli :

$ aws s3api get-bucket-cors --endpoint-url "http://s3-api.us-geo.objectstorage.softlayer.net" --bucket bucket_name
{
"CORSRules": [
    {
        "AllowedHeaders": [
            "authorization"
        ], 
        "MaxAgeSeconds": 3000, 
        "AllowedMethods": [
            "GET"
        ], 
        "AllowedOrigins": [
            "*"
        ]
    }
  ]
 }

I wonder if the problem is related to some misconfiguration with IBM Cloud API.

EDIT : My Object Storage instance is provisioned as IaaS which use access and secret key pairs.

PS: I've already opened a ticket in IBM cloud and they asked to redirect my request to stackoverflow.

2
Do you have a ticket # so I can follow up regarding why you were asked to post here? I just want to be sure that the correct process is being used by Support. - William 'Bill' Wentworth
Yes i do have : #58467769. Thanks - Omar_0x80

2 Answers

0
votes

In order to dissipate any doubt about possible issues from IBM cloud API side, you can try using REST calls like described here.

Syntax

GET https://{endpoint}/{bucket-name}?cors= # path style
GET https://{bucket-name}.{endpoint}?cors= # virtual host style

Sample request

GET /apiary?cors= HTTP/1.1
Authorization: Bearer {token}
Host: s3-api.us-geo.objectstorage.softlayer.net

For CURL samples review:

https://console.bluemix.net/docs/services/cloud-object-storage/cli/curl.html#using-curl-

I also recommend to review following links:

https://console.bluemix.net/docs/services/ibm-cos/index.html

https://console.bluemix.net/docs/services/cloud-object-storage/getting-started.html

0
votes

I know the question has some time but I was having the same issue and I was able to figure it out. The problem happens when object storage receives an object with spaces on its name.

So I just replaced spaces with _ and it worked like a charm.

My code to rename the files in JavaScript:

Var renamed file = new File([file], file.name.split(' ').join('_'), {type: file.type});

This resolved my problem, hope it does the same with yours.