Get started with Cloud Storage on Android

Cloud Storage for Firebase lets you upload and share user generated content, suchas images and video, which allows you to build rich media content into yourapps. Your data is stored in aGoogle Cloud Storage bucket — anexabyte scale object storage solution with high availability and globalredundancy.Cloud Storage for Firebase lets you securely upload these filesdirectly from mobile devices and web browsers, handling spotty networks withease.

Before you begin

  1. If you haven't already, make sure you've completed thegetting started guide for Android apps.This includes:

    • Creating a Firebase project.

    • Registering your Android app with the project,and connecting your app to Firebase by adding the Firebase dependencies,the Google services plugin, andyour Firebase config file (google-services.json) to your app.

  2. Make sure your Firebase project is on thepay-as-you-go Blaze pricing plan, whichis a requirement that started in October 2024 (see ourFAQs).If you're new to Firebase and Google Cloud, check if you're eligible for a$300 credit.

Create a defaultCloud Storage bucket

  1. From the navigation pane of theFirebase console, selectStorage.

    If your project is not yet on the pay-as-you-go Blaze pricing plan, then you'll beprompted to upgrade your project.

  2. ClickGet started.

  3. Select alocation for your default bucket.

  4. Configure theFirebase Security Rules for your default bucket. During development,considersetting up your rules for public access.

  5. ClickDone.

You can now view the bucket in theCloud StorageFiles tab of theFirebase console. Your default bucket name format isPROJECT_ID.firebasestorage.app.

Note: StartingOctober 30, 2024, all new defaultCloud Storage buckets have the name formatPROJECT_ID.firebasestorage.app. Any default buckets createdbeforethat date have the name formatPROJECT_ID.appspot.com. Learn more intheFAQs.

Set up public access

Cloud Storage for Firebase provides a declarative rules language that lets youdefine how your data should be structured, how it should be indexed, and whenyour data can be read from and written to. By default, read and write access toCloud Storage is restricted so only authenticated users can read or writedata. To get started without setting upAuthentication, you canconfigure your rules for public access.

This does makeCloud Storage open to anyone, even people not using yourapp, so be sure to restrict yourCloud Storage again when you set upauthentication.

Add theCloud Storage SDK to your app

In yourmodule (app-level) Gradle file(usually<project>/<app-module>/build.gradle.kts or<project>/<app-module>/build.gradle),add the dependency for theCloud Storage library for Android. We recommend using theFirebase Android BoMto control library versioning.

dependencies{// Import theBoM for the Firebase platformimplementation(platform("com.google.firebase:firebase-bom:34.9.0"))// Add the dependency for theCloud Storage library// When using theBoM, you don't specify versions in Firebase library dependenciesimplementation("com.google.firebase:firebase-storage")}

By using theFirebase Android BoM, your app will always use compatible versions of Firebase Android libraries.

(Alternative)  Add Firebase library dependencies without using theBoM

If you choose not to use theFirebase BoM, you must specify each Firebase library version in its dependency line.

Note that if you usemultiple Firebase libraries in your app, we strongly recommend using theBoM to manage library versions, which ensures that all versions are compatible.

dependencies{// Add the dependency for theCloud Storage library// When NOT using theBoM, you must specify versions in Firebase library dependenciesimplementation("com.google.firebase:firebase-storage:22.0.1")}

Set upCloud Storage in your app

  1. Make sure the Firebase config file (google-services.json) in your app'scodebase is updated with the name of your defaultCloud Storage bucket.

    1. Obtain your updated config file..

    2. Use this downloaded config file toreplace the existinggoogle-services.json file in your app's module (app-level) directory.

      Make sure that you only have this most recent downloaded config file inyour app and that its filename isn't appended with additionalcharacters, like(2).

    Note: Alternatively to replacing your config file, you can explicitlyspecify the bucket name when you create an instance ofFirebaseStorage(see next step). You can find the bucket name in theCloud StorageFiles tab of theFirebase console.
  2. Access yourCloud Storage bucket by creating an instance ofFirebaseStorage:

    Kotlin

    storage=Firebase.storage
    // Alternatively, explicitly specify the bucket name URL.// val storage = Firebase.storage("gs://BUCKET_NAME")

    Java

    FirebaseStoragestorage=FirebaseStorage.getInstance();
    // Alternatively, explicitly specify the bucket name URL.// FirebaseStorage storage = FirebaseStorage.getInstance("gs://BUCKET_NAME");

You're ready to start usingCloud Storage!

Next step? Learn how tocreate aCloud Storage reference.

Advanced setup

There are a few use cases that require additional setup:

The first use case is perfect if you have users across the world, and want tostore their data near them. For example, you can create buckets in the US,Europe, and Asia to store data for users in those regions to reduce latency.

The second use case is helpful if you have data with different access patterns.For example: you can set up a multi-regional or regional bucket that storespictures or other frequently accessed content, and a nearline or coldline bucketthat stores user backups or other infrequently accessed content.

In either of these use cases, you'll want touse multipleCloud Storage buckets.

The third use case is useful if you're building an app, like Google Drive, whichlets users have multiple logged in accounts (for instance, a personal accountand a work account). You canuse a custom Firebase Appinstance to authenticate each additional account.

Use multipleCloud Storage buckets

If you want to use aCloud Storage bucket other than the default bucket describedearlier in this guide, or use multipleCloud Storage buckets in a single app, youcan create an instance ofFirebaseStorage that references your custom bucket:

Kotlin

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

Java

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

Working with imported buckets

When importing an existingCloud Storage bucket into Firebase, you'llhave to grant Firebase the ability to access these files using thegsutil tool, included in theGoogle Cloud SDK:

gsutil -m acl ch -r -u service-PROJECT_NUMBER@gcp-sa-firebasestorage.iam.gserviceaccount.com gs://BUCKET_NAME

You can find your project number as described in theintroduction to Firebase projects.

This does not affect newly created buckets, as those have the default accesscontrol set to allow Firebase. This is a temporary measure, and will beperformed automatically in the future.

Use a custom Firebase App

If you're building a more complicated app using a customFirebaseApp, you cancreate an instance ofFirebaseStorage initialized with that app:

Kotlin

// Get the default bucket from a custom FirebaseAppvalstorage=Firebase.storage(customApp!!)// Get a non-default bucket from a custom FirebaseAppvalcustomStorage=Firebase.storage(customApp,"gs://my-custom-bucket")

Java

// Get the default bucket from a custom FirebaseAppFirebaseStoragestorage=FirebaseStorage.getInstance(customApp);// Get a non-default bucket from a custom FirebaseAppFirebaseStoragecustomStorage=FirebaseStorage.getInstance(customApp,"gs://my-custom-bucket");

Next steps

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-18 UTC.