How do you make many files public in Google Cloud Storage?

engineerchuan picture engineerchuan · Jan 17, 2013 · Viewed 37.2k times · Source

I have 1000 files in Google Cloud Storage to make public, or in general a directory hierarchy.

In the Web UI, I can only seem to make one at a time public.

Is there some way to do this.

Answer

fejta picture fejta · Jan 26, 2013

Run gsutil -m acl set -R -a public-read gs://bucket

  • The -m issues multiple requests at the same time.
  • The -R issues requests for every object in your bucket.
  • The -a issues requests for every version of every object.

See gsutil help acl for more info.

At the API layer gsutil issues the following HTTP request:

PUT /bucket/obj?acl HTTP/1.1
Host: storage.googleapis.com
x-goog-acl: public-read

You can see this by using the -D flag with gsutil:

gsutil -D setacl public-read gs://bucket/obj