What is Google Firebase Storage and How to Use It for Application Development?

Google Firebase offers many products which include Google Cloud Storage. Let’s get to know what Google Firebase Storage is and how to use it for application development.

4 min read
May 28, 2022

We all know Firebase is a Google Powered web and mobile application development platform. It comes with various functionalities that help developers to build full-fledged applications. Firebase projects also create Google Cloud storage where all the project data is stored.

Google Firebase Storage is one of the functionalities of Firebase that can be integrated with apps. It enables developers to leverage Google’s cloud security features right into the Firebase apps. The most common use of Firebase storage is to use it to store user-generated content easily in the database.

Some apps such as social media, blogging, or others need the functionality to let users upload, read, download, and even delete the content whenever needed.

Thus, Firebase storage comes in handy for developing such web applications and even mobile apps too. But what is exactly Firebase Storage? Let’s understand a bit about it:

What is Google Firebase Storage?

Google’s Firebase storage is a service that developers can use for various purposes including uploading, storing, and downloading files generated by app users. The best thing about this type of storage system is that there is no need for server-side coding.

Firebase Storage uses Google’s very own cloud storage buckets to store files that allow accessibility from both Google cloud and Firebase. The Cloud buckets are formed within a hierarchical structure.

Another great thing about Firebase cloud storage is how seamlessly it integrates with Firebase Authentication. This enables developers to organize the uploaded files based on each app user and implement access control if required. Further, the storage can scale automatically when needed so that you don’t have to worry when the storage gets too large.

Now that we know what Firebase Storage is and what it can do, let’s get to the main course of this post which is how to use it for application development.

How to Use Firebase Storage for Application Development?

For the sake of showing the process, I’ll explain how to get started with Firebase storage with Android Project. For the same, we’ll first have to add Firebase to the particular Android application before getting on with the firebase integration with your app. Once complete, let’s see what steps to follow:

Creating Default Cloud Storage Bucket

The first step is to create a default cloud storage bucket. Let’s see how you can do so:

  • From the navigation pane of the Firebase console, select the storage option and click on the Get started button.
  • You’ll be presented with some security messages about Cloud Storage data to review. During the development process, you must set up security rules for public access.
  • Next is to select a location for your default storage bucket. It’ll be your project’s default Google cloud platform resource location and will be used for GCP services. For projects with the Blaze plan, you can create multiple buckets each with its own location.
  • Once the location has been selected, click on done.

Set up Public Access

Firebase Cloud Storage provides declarative rules languages that allow you to define how your data should be structured. Further, it should define how your data be indexed and when it can be read from and written to.

By default, such access to read and write is restricted for Cloud Storage so that only authenticated users can access it. To access it without setting up the authentication, you must configure your rules for public access.

This will make Cloud Storage open to everyone and anyone even to people who do not use your app. So, make sure to restrict Cloud Storage again after you set up authentication.

Add the Cloud Storage SDK to Your App

To add the SDK, first declare the dependency using Firebase Android BoM for the Cloud Storage Android library in the Gradle-file module. Here’s how you can do so,

For Java Android:

dependencies {
    // Import the BoM for the Firebase platform
    implementation platform('com.google.firebase:firebase-bom:30.1.0')

    // Declare the dependency for the Cloud Storage library
    // When using the BoM, you don't specify versions in Firebase library dependencies
    implementation 'com.google.firebase:firebase-storage'
}

For Kotlin+KTX Android:

dependencies {
    // Import the BoM for the Firebase platform
    implementation platform('com.google.firebase:firebase-bom:30.1.0')

    // Declare the dependency for the Cloud Storage library
    // When using the BoM, you don't specify versions in Firebase library dependencies
    implementation 'com.google.firebase:firebase-storage-ktx'
}

Set up Cloud Storage

The first step to setting up and accessing your cloud storage bucket is to create an instance of FirebaseStorage. Here’s how you can do so:

For Java Android:

FirebaseStorage storage = FirebaseStorage.getInstance();

For Kotlin+KTX Android:

storage = Firebase.storage

Now you are ready to use Cloud Storage!

Advanced Setup

Few cases require an additional setup. This includes:

  • The first use case is using cloud storage buckets in multiple geographic regions. It’s perfect if you have users across the world.
  • The second use case is using the buckets in different storage classes. It’s particularly helpful if you have data with different access patterns.
  • The third use case is using cloud storage buckets with multiple authenticated users in the same app. It’s useful if you are building an app like Google Drive that lets users have multiple logged-in accounts.

Use Multiple Cloud Storage Buckets

If you want to use multiple cloud storage buckets or use another one than the default provided one, then create an instance of FirebaseStorage that references your custom bucket. Here’s how you can do so:

For Java Android:

// Get a non-default Storage bucket
FirebaseStorage storage = FirebaseStorage.getInstance("gs://my-custom-bucket");

For Kotlin+KTX Android:

// Get a non-default Storage bucket
val storage = Firebase.storage("gs://my-custom-bucket")

Next Steps

  • Enable app check to help ensure that only your apps can access your storage buckets.
  • Set up budget alerts for your Android app project through Google Cloud Console.
  • Monitor the usage and billing dashboard in the firebase console to get an overall picture of your project’s usage of Firebase services.
  • And finally, review the Firebase Launch Checklist.

Summing Up

Now we know what Google Firebase Storage is and how we can utilize it to develop a mobile app or even web applications. I have explained the process of how you can integrate it into the Android app. However, there are some prerequisites to it that you must keep in mind before you start off with the development process.

You may also like

thumbnail
Nov 1, 2021

DotNet 6: Let’s Get to Know What the Fuss Is All About

Since Microsoft has announced the release of its prestigious .Net 6 framework, it has created a buzz around the development community. So, let’s get to know what the fuss is all about.
4 min read
Read More
thumbnail
Jun 27, 2022

Let’s Dive Deep into What’s New with TypeScript 4.7

Want to know what’s new with TypeScript 4.7? Let’s get started.
4 min read
Read More
thumbnail
May 9, 2022

Angular at Google I/O 2022: What Can We Expect?

Google I/O is going to be held this year on 11th and 12th May 2022. So, what can we expect at this biggest tech fest of the year? What Angular team will surprise us with this year’s I/O? Let’s find out more about what’...
3 min read
Read More

Let’s Connect!

Work can be a fun when we know and understand each other well. Let's start conversation to new beginning
  • Give us a Call

    +91 63542 35108

    To discuss what we can do for you Give us a Call
  • Write to us

    connect@ashutec.com

    Tell us about your next project Write to us

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.