0

You might have to zoom in the picture, but I'm trying to update my bucket's CORS configuration by using the command
"gsutil cors set <CORS_JSON_FILE> gs://<BUCKET_NAME>"
but seems like it can't find my file even though it is clearly there?

jzhang172@cloudshell:~ (bionic-kiln-356221)$ gsutil cors set gs://portfolio-jzhang172/CORS_JSON_FILE.json gs://portfolio-jzhang172
OSError: No such file or directory.
jzhang172@cloudshell:~ (bionic-kiln-356221)$ gsutil cors set CORS_JSON_FILE.json gs://portfolio-jzhang172                                                                                                  
OSError: No such file or directory.
jzhang172@cloudshell:~ (bionic-kiln-356221)$ gsutil cors set CORS_JSON_FILE gs://portfolio-jzhang172                                                                                                       
OSError: No such file or directory.

https://i.stack.imgur.com/XxcSc.jpg

Snorlax
  • 4,425
  • 8
  • 37
  • 68

2 Answers2

2

For cloudshell, you can create the file in the command line and then link to it:

Create the file:

echo '[{"origin": ["*"],"responseHeader": ["Content-Type"],"method": ["*"],"maxAgeSeconds": 3600}]' > cors.json

Add it to your bucket

gsutil cors set cors.json gs://<your-bucket-name>

If you want to use the local file you created, you can download Google Cloud SDK, then type:

cd C:\path\to\your\json

gsutil cors set <cors.json> gs://<bucket-name>

****If you are new to the SDK, when it opens run these commands first:

gcloud auth login and complete login in your browser

gcloud set project <your-project-id>

AylaWinters
  • 1,121
  • 2
  • 7
  • 24
0

The error OSError: No such file or directory means that the command is looking for the file on your local file system and not in the cloud.

The cors-json-file specified on the command line should be a path to a local file containing a JSON document

Reference

John Hanley
  • 74,467
  • 6
  • 95
  • 159