Dan
Dan

Reputation: 5323

How can I use gsutil to only make my *.jpg and *.png images public?

I have a bucket with many subdirectories containing a variety of different files. How can I make only my images accessible publicly? The following is great for making everything public but I don't seem to be able to filter on extension.

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

Upvotes: 0

Views: 365

Answers (2)

Travis Hobrla
Travis Hobrla

Reputation: 5509

I'd recommend using gsutil acl ch, which will preserve all existing ACLs on your objects and make them publicly readable. This command should do the trick:

gsutil -m acl ch -u AllUsers:R gs://mybucket/**/*.png gs://mybucket/**/*.jpg

Using the canned acl (i.e., acl set -a public-read) can remove other ACL changes that you've made.

Upvotes: 2

Dan
Dan

Reputation: 5323

gsutil accepts wildcards.

So this works fine:

$ gsutil -m acl set -R -a public-read gs://mybucket/**/*.jpg
$ gsutil -m acl set -R -a public-read gs://mybucket/**/*.png

Upvotes: 0

Related Questions