Pages - Menu

Sunday, October 11, 2015

Hosting for your files instead of Google Drive #2 (Firebase)

In my previous blogpost I have described first alternative for hosting files instead of Google Drive - Google Storage.

Today I would like to introduce another alternative - Firebase. It is a real-time database for saving JSON objects through REST API. The Firebase also offers hosting for your files, which are served under HTTPS.  Moreover, a free plan is available. You can upload for hosting 5 GB with max. traffic 30 GB. There is also a paid plan, where you can get more storage/transfer and setup custom domain. (Firebase pricing)
Let's go!

1) First open console https://console.firebase.google.com/?pli=1 with your Google Account

2) Create new project (or import your Google Cloud project and connect to it)

3) Choose project name (I recommend to choose more memorable URL address lik apps-script-project.firebaseapp.com. Dont forget that must be unique)

4) Now you have to install firebase tools on your computer via npm.
Note. If you have never used npm to install app, please download and install nodejs https://nodejs.org/ (npm - node package manager is included)

If you have already installed nodejs, you can type into shell/command line
npm install -g firebase-tools

5) Login into your Google Account. Type
firebase login
and authorize access in opened browser

6) Type first command  to run code initialization.
firebase init

7) Then select Database row with arrows keys UP/DOWN and press SPACE key.
We want to confgure and deploy only Hosting options.
( ) Database
(*) Hosting
Press ENTER

8) Select Firebase project

9) Choose which directory will be setup as public (=contains files hosted on Firebase). Public is as a default opt

10) Don't configure as single-page app, because all assets will be redirect to index.html (press N)

11) The last step is to deploy files into Firebase by code (Rememeber, that you should be in your directory)
firebase deploy

12) Now you can access your project at URL name

http://apps-script-project.firebaseapp.com

Every deployment is logged in dashboard, where you can revert into any previous version/state.