如何与 GSUTIL 共享整个 Google Cloud Bucket

How to share entire Google Cloud Bucket with GSUTIL

是否有使用 GSUTIL 的命令允许我公开共享特定存储桶中的所有内容?现在,我不得不在控制台中的每个文件上单独检查 "share publicly"。

最好的方法是:

gsutil -m acl ch -u 'AllUsers:R' gs://your-bucket/**

将为存储桶中的每个现有对象更新 ACL。

如果您希望此存储桶中新创建的对象也是 public,您还应该 运行:

gsutil defacl ch -u 'AllUsers:R' gs://your-bucket

这个问题也被问到 here,但答案建议使用 acl set public-read,它的缺点是可能会改变您现有的 ACL。

$> gsutil acl ch -g All:R -r gs://bucketName

gsutil 是 GCS 的命令行实用程序。

"acl ch" 表示 "Modify an ACL."

"-g All:R"表示"include read permissions for all users."

“-r”表示"recursively"

剩下的就是路径了

如果你有很多文件并且你想要更快的速度,你可以使用 -m 来表示 "and also do this multithreaded!",像这样:

$> gsutil -m acl ch -g All:R -r gs://bucketName