Reputation: 1514
I am trying to set the files that are uploaded to a bucket to public by default.
When editing the bucket permissions, I get the popup below which I don't understand and I can't find any documentation about it. How do I set availability to the public?
The 'entity' selectboxes have the options: domain, group, user, project
The settings currently don't seem to set the files to public, because when I try to access a file through the url obtained with CloudStorageTools::getPublicUrl($fileName, false)
I get:
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
</Error>
Upvotes: 1
Views: 2455
Reputation: 22867
Active Google Cloud Shell
gsutil acl ch -u AllUsers:R gs://[BUCKET_NAME]/[OBJECT_NAME]
If successful, the response looks like the following example:
Updated ACL on gs://[BUCKET_NAME]/[OBJECT_NAME]
In the command, in the path after choosing the bucket, the CamelCase writing style must be respected.
I recommend applying the command to each file separately to get the short URL. Because if we assign the permission to the directory it will be possible to access the files but through a long URL.
Short URL:
https://storage.googleapis.com/[BUCKET_NAME]/[FILE_PATH]/[FILE]
Upvotes: -1
Reputation: 16384
You;ll want to set an ACL for that:
gsutil defacl set public-read gs://bucket
Upvotes: 5