What is Firebase Storage?

Firebase provides us with a storage mechanism, where we can create different buckets (in short rooms) to store a variety of items.

For example, one bucket can be used to store cat images, another bucket can be to store dog images. In short, you can store any kind of files onto Firebase storage.

Why do we need to use Firebase Storage?

Because Firebase Cloud Storage is a powerful yet easy-to-use tool for storing all sorts of objects. We can store images, audio, video, and other types of user content.

After a small introduction about Firebase Storage, let’s jump onto the main idea behind our article today, we will be looking into how one can integrate Node.js with Firebase storage and upload files onto the cloud.

What are the things we need to get started ?

  1. Gmail account.
  2. Basic knowledge of javascript.
  3. Familiarity with Node.js and how npm works.

Ok now without wasting any more time, let’s get onto the topic.

Install required Dependencies

Create a folder with any name and run the command npm init . That will create a package.json file and few other config related files. Now, to install dependencies, run the below command inside the folder that you just created.

  • npm i @google-cloud/storage
  • npm i express

Steps to start a Firebase project

  1. Open the Firebase console.
  2. Click “CREATE NEW PROJECT”.
  3. The “Create a project” window opens.
  4. The start screen of the Firebase console opens.
  5. The “Enter app details” screen opens.
  6. Continue the configuration by following the on-screen instruction.
  7. Check the server key after the project is created.
  8. Down the server key and store it on your local drive for now.

Now that we have installed dependencies and created a Firebase project, just create an index.js file and paste the below code. Don’t worry, we will go over the code in detail, to understand what is happening.

#nodejs #firebase #web-development #javascript #programming

How to Download files from Firebase Storage in Node.js
55.55 GEEK