How to Make Many Files Public in Google Cloud Storage

There are the following ways to make many files public in Google cloud storage.

  1. Method 1: Using the gsutil command-line tool
  2. Method 2: Using the Google Cloud Console
  3. Method 3: Using client libraries

Method 1: Using the gsutil command-line tool

To make many files public, run the following command, 

gsutil -m acl ch -r -u AllUsers:R gs://your_bucket_name/path/to/objects

Replace your_bucket_name with the name of your Cloud Storage bucket and path/to/objects with the path to the objects you want to make public.

You can also use this command to make multiple files public in Google cloud storage.

gsutil -m acl set -R -a public-read gs://bucket
  1. The -m issues multiple requests at the same time.
  2. The -R issues a request for every object in your bucket.
  3. The -a issues requests for every version of every object.

Method 2: Using the Google Cloud Console

  1. Go to the Google Cloud Console: https://console.cloud.google.com/
  2. Sign in with your Google account if you haven’t already.
  3. In the top-right corner of the page, click on the project dropdown menu to select the project containing your Cloud Storage bucket.
  4. Click on the navigation menu icon (three horizontal lines) in the page’s top-left corner.
  5. Scroll down to the “Storage” section and click “Browser.”
  6. Click on the bucket’s name containing the files you want to make public.
  7. Use the checkboxes to select the files you want to make public.
  8. Click on the “Edit permissions” button (it looks like a pencil) above the file list.
  9. In the “Edit object permissions” dialog, click the “Add entry” button.
  10. In the new row, set “Entity” to “User,” set “Name” to “allUsers,” and set “Access” to “Reader.”
  11. Click on the “Save” button to apply the changes.

Method 3: Using client libraries

Here’s an example using the Google Cloud Storage client library for Python to make multiple files public.

Step 1: Install the Google Cloud Storage Python library

pip install google-cloud-storage

Step 2: Create a Python script with the following code

from google.cloud import storage


def make_files_public(bucket_name, prefix):
  client = storage.Client()
  bucket = client.get_bucket(bucket_name)
  blobs = bucket.list_blobs(prefix=prefix)

  for blob in blobs:
    blob.make_public()

 print(f"Made all files in {prefix} public.")


# Replace with your bucket name and path to objects
bucket_name = "your_bucket_name"
prefix = "path/to/objects"

make_files_public(bucket_name, prefix)

Replace your_bucket_name with the name of your Cloud Storage bucket and path/to/objects with the path to the objects you want to make public.

Following these steps, you can publicize many files in Google Cloud Storage using the Google Cloud Console, gsutil, or client libraries.

That’s it.

Leave a Comment