Firebase Storage: What It Is and How It Works

Firebase is a web and mobile application development platform powered by Google. Cloud Storage is incorporated natively into the Firebase architecture.

When creating Firebase projects, you’re also creating Google Cloud projects, because this is where Firebase stores data. This integration enables you to leverage Google Cloud security features for Firebase apps, as well as manage media directly through your storage account. 

This article explains how Firebase architecture works, and walks you through the process of  accessing and uploading files, setting up monitoring, and configuring user-based security rules.

In this article, you will learn:

  • What is Firebase storage?
  • Firebase architecture in the cloud
  • Firebase storage methods

What Is Firebase Storage?

Firebase is a platform for web and mobile application development. It was created by Firebase, Inc in 2011 and acquired in 2014 by Google. Firebase Storage is storage incorporated into the Firebase platform. You can use it to store and manage media generated by web and mobile app users. 

The Firebase SDK lets developers to work with Firebase programmatically, including cloud storage functionality. It enables them to download and upload files from and to clients directly. It also includes features that enable transfers to be resumed or retried in cases of poor connectivity. 

Firebase alternative Sign Up

How Does Cloud Storage Fit into the Firebase Architecture?

The Firebase Architecture is made of several components, which work together to provide a framework and infrastructure for developing and hosting web and mobile applications. 

  • Firebase Cloud Storage—also called Firebase File Storage or Firebase Object Storage, is an object storage service offered on Google Cloud Platform. When Google Cloud Storage is incorporated into Firebase apps, you gain access to Google security measures and the ability to secure any uploads or downloads in your app. Through the SDK you can also manage your media and access it directly from your storage account. Integration is supported for Android, C++, iOS, Unity, and Web apps.
  • Cloud Firestore—a scalable, flexible database service for server, web, and mobile development. It serves as a NoSQL document database. You can use it to store, query, and sync your app data. It is supported for Android, iOS, and web applications. 
  • Authentication—included in the SDK in the form of UI libraries. You can use it as a backend service to authenticate app users via password, phone numbers, or federated ID. Federated options include Google, Twitter, and Facebook. It is supported for Android, iOS, and web applications.
  • Hosting—provides production-grade hosting for your web content. With this component you can deploy apps and serve dynamic or static content via a global content delivery network (CDN). You can also combine the hosting component with Cloud Functions to develop and host microservices. Only web applications are supported.
  • Cloud Functions—enables you to automate code in your backend in response to event triggers. Events can be triggered by HTTPS requests or Firebase features. Cloud Functions are supported for Android, C++, Unity, iOS, and web applications. 

Keep reading to know more about cloud storage for Firebase.

Firebase Storage Methods

When using Firebase storage, several methods can help you simplify management, monitor your status, and improve your security. 

Accessing Files Through References

Although Firebase Storage uses a real-time database you can access data via a familiar file/folder system. When accessing files, you simply need to call the reference where your file is stored. References also enable you to control where files are stored and how files are labeled. 

To access files, you can use the following code (for web applications, similar code is available for Android or iOS via the relevant SDKs):

var storageRef = firebase.storage.ref(“folderName/file.jpg”);

Uploading Files 

Uploading files is easy as long as you know the reference for where you want your file stored. With web apps, you can upload files via an <input type=”file” /> element. When uploading files from Android and iOS, you can upload files from memory or from a stream. 

To configure file uploads, you can use the following code:

Monitor Progress with Tasks

Using Firebase Storage’s built-in UploadTask or DownloadTasks listeners you can monitor the progress of your file transfers. These listeners provide a snapshot of your file status, including total file size and how much data has already been transferred. You can then use this information to calculate the percentage completed or to update your app UI.

To configure monitoring, you can use the following code, which is a an example specific to file uploads.

For further information, please read Firebase Storage Docs.

Conclusion

Firebase enables you to natively use Cloud Storage when developing web and mobile applications. Firebase Storage is an object storage service you can access via Google Cloud Platform.

When using Google Firebase Storage, you can access files through references, easily upload files, and also monitor progress with tasks. You can also use cloud functions to automate backend code, as well as use UI libraries to authenticate app users. 

Want to know more about Firebase? Please read the articles Firebase – Secrets Unlocked and Firebase Pricing for Dummies.

Firebase alternative Sign Up

General FAQ

What is Firebase?

Firebase is a platform for web and mobile application development. It was created by Firebase, Inc in 2011 and acquired in 2014 by Google.

How does Firebase handle file storage?

– You can use it to store and manage media generated by web and mobile app users. 
– The Firebase SDK lets developers to work with Firebase programmatically, including cloud storage functionality.
– It enables them to download and upload files from and to clients directly.

How does the Firebase architecture look like?

The key components of Firebase architecture are:
– Cloud Storage
– Cloud Firestore
– Authentication
– Hosting
– Cloud Functions

Where is Firebase data stored?

Firebase uses Google Cloud as the underlying infrastructure and stores data on the Google Cloud Storage bucket.


Leave a reply

Your email address will not be published.