Following Google docs, when using GoogleCloud Storage console:
mysef@myproject:~$ cat cors-json-file.json
[
{
"origin": ["*"],
"method": ["GET"],
"maxAgeSeconds": 3600
}
]
then I get the following error:
myself@myproject:~$ gsutil cors set cors-json-file.json gs://mybucket
Setting CORS on gs://mybucket/...
ArgumentException: JSON CORS data could not be loaded from: [
{
"origin": ["*"],
"method": ["GET"],
"maxAgeSeconds": 3600
}
]
same error when I remove "method", "maxAgeSeconds" or add "responseHeader".
Specify Origins that you want to allow for cross origin resource sharing with this Cloud Storage bucket. For example, https://origin1.example.com . If the origin in a browser's request matches an origin in your CORS configuration, Cloud Storage returns Access-Control-Allow-Origin to the browser.
Cross Origin Resource Sharing (CORS) allows interactions between resources from different origins, something that is normally prohibited in order to prevent malicious behavior.
A CORS configuration is a document that defines rules that identify the origins that you will allow to access your bucket, the operations (HTTP methods) supported for each origin, and other operation-specific information. In the S3 console, the CORS configuration must be a JSON document.
after so many tries, I ended up with modifing json file to:
$ cat cors-json-file.json
[{
"origin": ["*"],
"method": ["GET"],
"maxAgeSeconds": 3600
}]
and... it worked! Note that example from Google documentation is my first case (with [{ on 2 lines)
I had the same problem and it was caused by the type of quotes used. By opening the json-file in a plain text editor and change the quote to standard ones fixed the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With