react-dropzone-uploader
react-dropzone-uploader copied to clipboard
Using react-dropzone-uploader with Google Cloud Storage
I've tried using react-dropzone-uploader with GCS and couldn't get rid of CORS problems. After some trial-and-error, I found the problem. The requests are sent with an X-Requested-With
header by default, which needs to be specifically allowed in GCS. To do that, create a JSON file with the following content:
[
{
"maxAgeSeconds": 3600,
"method": ["GET", "HEAD", "PUT"],
"origin": ["*"],
"responseHeader": [
"Content-Type",
"Access-Control-Allow-Origin",
"X-Requested-With"
]
}
]
Then apply those rules to your bucket:
gsutil cors set the-json-file.json gs://your-bucket
It might be nice to include this in the docs for others who might have the same use case :)