I failed to upload a file to Cloud Storage on GCP from Retool many times and always got the error below:
query: Failed to upload. This might be due to a CORS issue on the bucket, so please double check that your CORS settings are correct.
Actually, I made cors.json with the command below on Cloud Shell:
vi cors.json
Then, wrote the code below to cors.json:
[
{
"origin": ["https://myorigin.retool.com"],
"method": ["*"],
"responseHeader": ["Content-Type"],
"maxAgeSeconds": 3600
}
]
Finally, set cors.json for my bucket in Cloud Storage, GCP running the command below:
gsutil cors set cors.json gs://mybucket-bc123.appspot.com
In addition, the access control of the bucket is "Fine-grained".
Are there any solutions to upload a file to Cloud Storage on GCP from Retool?
Add "x-goog-acl" to "responseHeader" for the access control of the bucket "Fine-grained":
[
{
"origin": ["https://myorigin.retool.com"],
"method": ["*"],
"responseHeader": ["Content-Type", "x-goog-acl"],
"maxAgeSeconds": 3600 // ↑↑↑ Here ↑↑↑
}
]
In addition, if the access control of the bucket is "Uniform":
"x-goog-acl" is not needed:
[
{
"origin": ["https://myorigin.retool.com"],
"method": ["*"],
"responseHeader": ["Content-Type"],
"maxAgeSeconds": 3600
}
]