Access public data

Some data stored in Cloud Storage isconfigured so that it'sreadable by anyone at any time. Thispublic data can be accessed in severalways, depending on how you want to work with the data.

API Link

Note: Accessing this link does not require authentication. It is suitable,for example, as a link in a web page, or for downloading with a command-linetool such as cURL.
  1. Get the name of the public object and the bucket that stores the object.

  2. Use the following URI to access an object in the bucket:

    https://storage.googleapis.com/BUCKET_NAME/OBJECT_NAME

For example, the Google public bucketgcp-public-data-landsat containstheLandsat public dataset. You can link to the publicly shared objectLC08/01/001/003/LC08_L1GT_001003_20140812_20170420_01_T2/LC08_L1GT_001003_20140812_20170420_01_T2_B3.TIFwith the link:

https://storage.googleapis.com/gcp-public-data-landsat/LC08/01/001/003/LC08_L1GT_001003_20140812_20170420_01_T2/LC08_L1GT_001003_20140812_20170420_01_T2_B3.TIF

Console

Note: Accessing public data with theGoogle Cloud console requires you tosign in with a user account. The method described in theAPI link tabprovides the most broadly applicable way to access individual publicobjects. The method described in theCommand line tab provides the mostefficient way to access collections of data.
  1. Get the name of the public object and the bucket that stores the object.

  2. Using a web browser, access the object with the following URI (youare asked to sign in if you are not already signed in):

    https://console.cloud.google.com/storage/browser/_details/BUCKET_NAME/OBJECT_NAME

  3. If the public haspermission to list the bucket's contents, you canlist all the objects in the bucket with the following URI:

    https://console.cloud.google.com/storage/browser/BUCKET_NAME

For example, the Google public bucketgcp-public-data-landsat containstheLandsat public dataset. You can access the bucket with:

https://console.cloud.google.com/storage/browser/gcp-public-data-landsat

Command line

Note: Accessing public data with the gcloud CLI does not requireauthentication. This tool is suited for general access to buckets thatcontain publicly listable public data.
  1. If you don't have the gcloud CLI,follow these instructions to install it.

    • When installing the gcloud CLI, if you don't want toauthenticate, skip the step of running the commandgcloud init,and instead run the following command:

      gcloud config set auth/disable_credentials True
  2. Get the name of the public object and the bucket that stores the object.

  3. Ifpermission to list the bucket's contents is granted to thepublic, you can list some or all of the objects contained in the bucketby using thels command.

    For example, the Google public bucketgcp-public-data-landsat containstheLandsat public dataset. You can list objects with the prefixLC08/01/001/003/LC with the following command:

    gcloud storage ls --recursive gs://gcp-public-data-landsat/LC08/01/001/003/LC*
    Note: Shells (like bash and zsh) can attempt to expand wildcards beforepassing the arguments to the gcloud CLI. To avoid theseproblems, surround the wildcarded expression with single quotes (onLinux) or double quotes (on Windows). For more information, seePotentially Surprising Behavior When Using Wildcards.
  4. Download specific public objects contained in the bucket by using thecp command.

    For example, the following command downloads a file from the bucketgcp-public-data-landsat to your local directory:

    gcloud storage cp gs://gcp-public-data-landsat/LC08/01/001/003/LC08_L1GT_001003_20140812_20170420_01_T2/LC08_L1GT_001003_20140812_20170420_01_T2_B3.TIF .

Client libraries

C++

For more information, see theCloud StorageC++ API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

namespacegcs=::google::cloud::storage;[](std::stringconst&bucket_name,std::stringconst&object_name){// Create a client that does not authenticate with the server.autoclient=gcs::Client{google::cloud::Options{}.set<google::cloud::UnifiedCredentialsOption>(google::cloud::MakeInsecureCredentials())};// Read an object, the object must have been made public.gcs::ObjectReadStreamstream=client.ReadObject(bucket_name,object_name);intcount=0;std::stringline;while(std::getline(stream,line,'\n')){++count;}if(stream.bad())throwgoogle::cloud::Status(stream.status());std::cout <<"The object has " <<count <<" lines\n";}

C#

For more information, see theCloud StorageC# API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

usingGoogle.Cloud.Storage.V1;usingSystem;usingSystem.IO;publicclassDownloadPublicFileSample{publicstringDownloadPublicFile(stringbucketName="your-bucket-name",stringobjectName="your-object-name",stringlocalPath="path/to/download/object/to"){varstorage=StorageClient.CreateUnauthenticated();usingvaroutputFile=File.OpenWrite(localPath);storage.DownloadObject(bucketName,objectName,outputFile);Console.WriteLine($"Downloaded public file {objectName} from bucket {bucketName} to {localPath}.");returnlocalPath;}}

Go

For more information, see theCloud StorageGo API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

import("context""fmt""io""time""cloud.google.com/go/storage""google.golang.org/api/option")// downloadPublicFile downloads a public object.funcdownloadPublicFile(wio.Writer,bucket,objectstring)([]byte,error){// bucket := "bucket-name"// object := "object-name"ctx:=context.Background()// Create a client that does not authenticate with the server.client,err:=storage.NewClient(ctx,option.WithoutAuthentication())iferr!=nil{returnnil,fmt.Errorf("storage.NewClient: %w",err)}deferclient.Close()ctx,cancel:=context.WithTimeout(ctx,time.Second*50)defercancel()rc,err:=client.Bucket(bucket).Object(object).NewReader(ctx)iferr!=nil{returnnil,fmt.Errorf("Object(%q).NewReader: %w",object,err)}deferrc.Close()data,err:=io.ReadAll(rc)iferr!=nil{returnnil,fmt.Errorf("io.ReadAll: %w",err)}fmt.Fprintf(w,"Blob %v downloaded.\n",object)returndata,nil}

Java

For more information, see theCloud StorageJava API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

importcom.google.cloud.storage.BlobId;importcom.google.cloud.storage.Storage;importcom.google.cloud.storage.StorageOptions;importjava.nio.file.Path;publicclassDownloadPublicObject{publicstaticvoiddownloadPublicObject(StringbucketName,StringpublicObjectName,PathdestFilePath){// The name of the bucket to access// String bucketName = "my-bucket";// The name of the remote public file to download// String publicObjectName = "publicfile.txt";// The path to which the file should be downloaded// Path destFilePath = Paths.get("/local/path/to/file.txt");// Instantiate an anonymous Google Cloud Storage client, which can only access public filesStoragestorage=StorageOptions.getUnauthenticatedInstance().getService();storage.downloadTo(BlobId.of(bucketName,publicObjectName),destFilePath);System.out.println("Downloaded public object "+publicObjectName+" from bucket name "+bucketName+" to "+destFilePath);}}

Node.js

For more information, see theCloud StorageNode.js API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

/** * TODO(developer): Uncomment the following lines before running the sample. */// The ID of your GCS bucket// const bucketName = 'your-unique-bucket-name';// The ID of your GCS file// const srcFilename = 'your-file-name';// The path to which the file should be downloaded// const destFileName = '/local/path/to/file.txt';// Imports the Google Cloud client libraryconst{Storage}=require('@google-cloud/storage');// Creates a clientconststorage=newStorage();asyncfunctiondownloadPublicFile(){constoptions={destination:destFileName,};// Download public file.awaitstorage.bucket(bucketName).file(srcFileName).download(options);console.log(`Downloaded public file${srcFileName} from bucket name${bucketName} to${destFileName}`);}downloadPublicFile().catch(console.error);

Python

For more information, see theCloud StoragePython API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

fromgoogle.cloudimportstoragedefdownload_public_file(bucket_name,source_blob_name,destination_file_name):"""Downloads a public blob from the bucket."""# bucket_name = "your-bucket-name"# source_blob_name = "storage-object-name"# destination_file_name = "local/path/to/file"storage_client=storage.Client.create_anonymous_client()bucket=storage_client.bucket(bucket_name)blob=bucket.blob(source_blob_name)blob.download_to_filename(destination_file_name)print("Downloaded public blob{} from bucket{} to{}.".format(source_blob_name,bucket.name,destination_file_name))

Ruby

For more information, see theCloud StorageRuby API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

defdownload_public_filebucket_name:,file_name:,local_file_path:# The name of the bucket to access# bucket_name = "my-bucket"# The name of the remote public file to download# file_name = "publicfile.txt"# The path to which the file should be downloaded# local_file_path = "/local/path/to/file.txt"require"google/cloud/storage"storage=Google::Cloud::Storage.anonymousbucket=storage.bucketbucket_name,skip_lookup:truefile=bucket.filefile_namefile.downloadlocal_file_pathputs"Downloaded public object#{file.name} from bucket#{bucket} to#{local_file_path}"end

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.