Serving Up Data From Cloud Storage

Prefer to listen rather than read? Check out this post on the podcast!

When it comes to the cloud, there’s more than one way to serve a file. In this post, we’ll walk you through all the ways to serve data from Cloud Storage—so you can determine the best fit for your needs!

You can use Cloud Storage to serve assets to your customers, and depending on your application, there are a variety of methods you might use to get that data out of a Cloud Storage bucket. In this post, we’ll cover four ways to serve those assets, but feel free to read more in the documentation, or for general, conceptual information on uploads and downloads, read this

Here we go!

Client Libraries

First, we’ve got Client Libraries. If you need to download assets directly into your existing application, this is something for you to explore!

And trust me when I say…we speak your language. With code samples in C++, C#, Go, Java, Node.js, PHP, Python, and Ruby—we’ve got you covered. Check out the documentation for more.

 Here’s an example of downloading from your Cloud Storage bucket using Python:

Language: Python

from import storage
def download_blob(bucket_name, source_blob_name,
    """Downloads a 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()
    bucket = storage_client.bucket(bucket_name)
    blob = bucket.blob(source_blob_name)


Up next, you have the gsutil application. gsutil is a Python application that lets you access Cloud Storage from the command line. 

For our purposes, the cp command allows you to upload files from your local machine to google cloud. 

For example, running this command will download from a Cloud Storage bucket to a local path on your device.

Additionally, gsutil comes with a plethora of options to configure to your specific use case; like the -m command, which allows for copy options to occur in parallel.


You can also directly go to the REST APIS, using other programs like cURL to fetch your files directly and allowing the user to log in with OAuth. More on that here.

curl -X GET \
  -H "Authorization: Bearer OAUTH2_TOKEN" \

Cloud Console

Finally, you can always access your objects right from the Cloud Console. Simply select the desired bucket, or object, and click “Download” in the handy “more actions” drop down menu. This is a great way to grab individual files when you’re debugging or going through things manually.

Note: For some object types, selecting “Download” opens the object in the browser. To download these objects to your local computer, right-click on “Download” and select “Save Link As.”

What’s Next?

Retrieving files is really just the start, and you’ll want to make sure you’ve got a handle on controlling access – You know we’ve got another post for that, so stay tuned!

Learn more about your storage options in Cloud Storage Bytes, or check out the documentation for more information, including tutorials.

By Jenny Brown(Cloud Developer Advocate)
Source: Google Cloud Blog

For enquiries, product placements, sponsorships, and collaborations, connect with us at We'd love to hear from you!

Our humans need coffee too! Your support is highly appreciated, thank you!

Previous Article
Google Cloud | Bigtable

Cloud Bigtable + Cloud Memorystore: Faster Together

Next Article
Robot | Automation

Automation Anywhere And Google Cloud Partner To Enable Enterprises To Automate Common Business Processes

Related Posts