Skip to Content

Publishing static content in one click on Cloud Storage

Making static content stored on Google Cloud Storage available publicly easily

Posted on 2 mins read

When you need to quickly publish content on the web, plenty of options are available to you. Your ISP might be offering you some web space, you could use the millions of services in the wild (like blogging platforms or CMS solutions). But you can also go with Google App Engine or Firebase. However, in this tip, today, we’re going to look into storing a static web site or static assets for your mobile apps, on Google Cloud Storage.

Storing content on GCS

In our first tip, we talked about how to upload content faster to a GCS bucket. We used the gsutil command-line interface, using the -r flag, with the cp sub-command to copy the files from our local filesystem to the bucket.

You can also use the web cloud console to upload content from your web browser. When you’re inside the console, in the Cloud Storage section, you should see buttons to upload files or upload a folder.

Making the assets public

From the web console, making assets public is one-click away! Along your assets, you’ll see a checkbox in the share publicly column, which will make your asset public. Once clicked, you’ll even get a link to the public URL of the published asset:

Making an asset public in one click

Uploading assets and publishing them in one line

As covered in this article by Valentin, you can upload and make public your assets in one line:

gsutil cp -r -a public-read my-assets/* gs://my-bucket/

In particular, note the -a public-read part which makes the assets public in one go.

Bonus point

If you want to have a friendlier URL, you might want to consider using your own domain name, instead of the https://storage.googleapis.com/ prefix. You can read more about this in the documentation about Hosting a static website on Cloud Storage.

comments powered by Disqus