Kirk Sefchik
Kirk Sefchik

Reputation: 813

How to share entire Google Cloud Bucket with GSUTIL

Is there a command using GSUTIL that will allow me to share publicly everything in a specific Bucket? Right now, I'm forced to go through and check "share publicly" individually on EVERY SINGLE FILE in the console.

Upvotes: 3

Views: 331

Answers (2)

Travis Hobrla
Travis Hobrla

Reputation: 5511

The best way to do this is:

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

will update ACLs for each existing object in the bucket.

If you want newly created objects in this bucket to also be public, you should also run:

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

This question was also asked here but the answer recommends using acl set public-read which has the downside of potentially altering your existing ACLs.

Upvotes: 5

Brandon Yarbrough
Brandon Yarbrough

Reputation: 38369

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

gsutil is the command-line utility for GCS.

"acl ch" means "Modify an ACL."

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

"-r" means "recursively"

and the rest is the path.

If you have a whole lot of files and you want MORE SPEED, you can use -m to mean "and also do this multithreaded!", like so:

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

Upvotes: 0

Related Questions