5-ish ways to get your data into Cloud Storage

So you’ve created your buckets, and now you want to use the power of the cloud to serve your content. With a can-do attitude and the details of this post, you’ll learn how to get your data into Cloud Storage with a variety of upload methods. Let’s go!

When you upload an object to your Cloud Storage bucket, it will consist of the data you want to store, along with any associated metadata. When it comes to the actual uploading, you’ve got a few different options to choose from, which we’ll go over below. For more detail, check out the documentation. And for general, conceptual information on uploads and downloads, read this.

Cloud console

Pro-Tip: folder uploads are also supported if you’re using the Chrome browser.

gsutil

For this, we provide the gsutil tool. gsutil is a Python application that lets you access Cloud Storage from the command line, providing you with the ability to do all sorts of things like creating buckets, moving objects, or even editing metadata.

To use it, run the gsutil program with a variety of command line options. For example, this command uploads a directory of files from your local machine to your Cloud Storage bucket using parallel upload.

And this command lists out specific objects that have a version-specific URL using a wildcard.

More cool stuff you can do with the gsutil tool can be found in this documentation.

Client libraries

And before you even ask about language, with options in C++, C#, Go, Java, Node.js, PHP, Python, and Ruby — we’ve got you covered.

For example, check out this Python code to upload an object to a Cloud Storage bucket:

from google.cloud import storage

def upload_blob(bucket_name, source_file_name, destination_blob_name):

“””Uploads a file to the bucket.”””

# bucket_name = “your-bucket-name”

# source_file_name = “local/path/to/file”

# destination_blob_name = “storage-object-name”

storage_client = storage.Client()

bucket = storage_client.bucket(bucket_name)

blob = bucket.blob(destination_blob_name)

blob.upload_from_filename(source_file_name)

Check out even more code samples here.

JSON and XML

POST /OBJECT_NAME HTTP/2

Host: BUCKET_NAME.storage.googleapis.com

Date: DATE

Content-Length: REQUEST_BODY_LENGTH

Content-Type: MIME_TYPE

X-Goog-Resumable: start

Authorization: AUTHENTICATION_STRING

Cloud Storage Transfer Appliance

We ship you a fancy device, you connect it, add your data, and send it back to us. Plus you get this cool looking box on your desk for a while, which can be a great conversation starter, if you’re into that kind of thing. More details here.

More clouds, more problems? Not so!

Now What?

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