Set all files in Google Cloud Storage Bucket to pu

2019-07-23 08:32发布

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>

enter image description here

2条回答
成全新的幸福
2楼-- · 2019-07-23 09:01

Making Data Public

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]
查看更多
霸刀☆藐视天下
3楼-- · 2019-07-23 09:04

You;ll want to set an ACL for that:

gsutil defacl set public-read gs://bucket

查看更多
登录 后发表回答