Serving up data from Cloud Storage
Jenny Brown
Developer Relations Engineer
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:
gsutil
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.
REST APIs
You can also directly go to the REST APIS, using other programs likecURL
to fetch your files directly and allowing the user to log in with OAuth. More on that here.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.