This article's content
Google Cloud Storage

Storage Classes

All storage classes have in common:

  • Unlimited storage
  • Worldwide accessibility
  • low latency and high durability
  • geo-redundancy
# list buckets within a project
gsutil ls

# list files and folders within a bucket
gsutil ls gs://my-bucket-name

# download from bucket to current folder
gsutil cp gs://my-bucket-name/myfile.txt

# upload to a bucket
gsutil cp upload-me.txt gs://my-bucket-name/uploaded.txt

# enable versioning for a bucket
gsutil versioning set on gs://my-bucket-name

# list all versions of a file
gsutil ls -al gs://my-bucket-name/myfile.txt

# overwrite current version of a file.txt with an earlier version
# we got <id-of-earlier-version> using command above
gs util cp gs://my-bucket-name/myfile.txt#<id-of-earlier-version> gs://my-bucket-name/myfile.txt

Naming conventions for your buckets

CORS

CORS must be enabled to allow your web application to communicate with a bucket.

# cors-config-file.json
[
  {
    "origin": ["http://<server-ip>"],
    "responseHeader": ["*"],
    "method": ["*"],
    "maxAgeSeconds": 3600,
  }
]
gsutil cors set cors-config-file.json gs://my-bucket-name

Access controlling buckets

About Author

Mathias Bothe To my job profile

I am Mathias, born 40 years ago in Heidelberg, Germany. Today I am living in Munich and Stockholm. I am a passionate IT freelancer with more than 16 years experience in programming, especially in developing web based applications for companies that range from small startups to the big players out there. I am founder of bosy.com, creator of the security service platform BosyProtect© and initiator of several other software projects.