Question

I want to make the bucket publically readable (so each file added will have a "shared publically link")

I tried to change update bucket from the JSON API (currently from the "Try it" on the API reference (https://developers.google.com/storage/docs/json_api/v1/buckets/update) and add to the bucket predefinedAcl:PublicRead

The respose I get seems to be what I needed:

...
  {

   "kind": "storage#bucketAccessControl",
   "id": "<bucket name>/allUsers",
   "selfLink": "https://content.googleapis.com/storage/v1/b/<bucket name>/acl/allUsers",
   "bucket": "<bucket name>",
   "entity": "allUsers",
   "role": "READER",
   "etag": "CAI="
  }
...

However, when I add a new file to the bucket I dont have the "shared publicly" checkbox checked.

What am I missing?

** EDIT ** A direct link (thanks to the accepted answer) to the json relevant command: https://developers.google.com/storage/docs/json_api/v1/defaultObjectAccessControls/update

Was it helpful?

Solution

Are you confusing bucket and object ACLs? Changing the bucket ACL to public-read will let people list the bucket contents. To download the objects themselves you need to set each object ACL to public read. Finally, to have future objects be publicly readable by default, you would change the bucket's default object ACL to public-read (see also the full GCS docs).

OTHER TIPS

Instead of JSON API it is easier to set the GCS Bucket to be publically viewable using gsutil:

Use acl to set public-read on current bucket objects

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

Use defacl to set as default for future uploads:

gsutil -m defacl set public-read gs://BUCKET_NAME
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top