If you are planning on using the Direct Upload feature, you’ll need to set a CORS policy on your bucket in Google Cloud Storage.
To do this, you’ll need to install the gsutil
command line tool. You can download and install that from here: Download and Install gsutil. Be sure to follow the steps to setup authentication.
You’ll need to define your CORS policy in a JSON file. Use this sample policy as a starting point:
[ { "origin": ["https://yourdomain.com"], "responseHeader": ["*"], "method": ["GET", "HEAD", "DELETE", "POST", "PUT", "OPTIONS"], "maxAgeSeconds": 3600 } ]
Be sure to change https://yourdomain.com
to your actual domain, and possibly add more domains for your dev or staging environments.
Crack open a terminal and type the following:
gsutil cors set yourjsonfile.json gs://your-bucket-name
Obviously replace yourjsonfile.json
with the name of the JSON file you created in the previous step and change gs://your-bucket-name
to the name of your bucket.
Verify the CORS policy has been set correctly with:
gsutil cors get gs://your-bucket-name
That’s it, CORS has been set and you now are capable of performing Direct Uploads with Media Cloud.