Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud Storage: bulk edit ACLs

We are in the process of moving our servers into the Google Cloud Compute Engine and starting to look the Cloud Storage as a CDN option. I uploaded about 1,000 files through the Developer Console but the problem is all the Object Permissions for All Users is set at None. I can't find any way to edit all the permissions to give All Users Reader access. Am I missing something?

like image 872
Brad Wickwire Avatar asked Dec 18 '25 01:12

Brad Wickwire


2 Answers

You can use the gsutil acl ch command to do this as follows:

gsutil -m acl ch -R -g All:R gs://bucket1 gs://bucket2/object ...

where:

  • -m sets multi-threaded mode, which is faster for a large number of objects
  • -R recursively processes the bucket and all of its contents
  • -g All:R grants all users read-only access

See the acl documentation for more details.

You can use Google Cloud Shell as your console via a web browser if you just need to run a single command via gsutil, as it comes preinstalled in your console VM.

like image 92
Misha Brukman Avatar answered Dec 21 '25 01:12

Misha Brukman


In addition to using the gsutil acl command to change the existing ACLs, you can use the gsutil defacl command to set the default object ACL on the bucket as follows:

gsutil defacl set public-read gs://«your bucket»

You can then upload your objects in bulk via:

gsutil -m cp -R «your source directory» gs://«your bucket»

and they will have the correct ACLs set. This will all be much faster than using the web interface.

like image 34
Paul J. Ste. Marie Avatar answered Dec 20 '25 23:12

Paul J. Ste. Marie