Get started with Cloud Storage on Flutter Stay organized with collections Save and categorize content based on your preferences.
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
If you haven't already, make sure you've completed thegetting started guide for Flutter apps.This includes:
Creating a Firebase project.
Installing and initializing the Firebase SDKs for Flutter.
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 default Cloud Storage bucket
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.
ClickGet started.
Select alocation for your default bucket.
Buckets in
,US-CENTRAL1 , andUS-EAST1 can take advantage of the"Always Free" tier forGoogle Cloud Storage.Buckets in all other locations followGoogle Cloud Storage pricing and usage.US-WEST1If you'd like, you can latercreate multiple buckets, each with itsown location.
Configure theFirebase Security Rules for your default bucket. During development,considersetting up your rules for public access.
ClickDone.
You can now view the bucket in theCloud StorageFiles tab of theFirebase console. Your default bucket name format isPROJECT_ID.firebasestorage.app
PROJECT_ID.firebasestorage.appPROJECT_ID.appspot.comSet 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 upFirebase Authentication, you canconfigure your rules for public access.
This does make Cloud Storage open to anyone, even people not using yourapp, so be sure to restrict your Cloud Storage again when you set upauthentication.
Add the Cloud Storage SDK to your app
From the root of your Flutter project, run the following command to installthe plugin:
flutterpubaddfirebase_storageOnce complete, rebuild your Flutter application:
flutterrunImport the plugin in your Dart code:
import'package:firebase_storage/firebase_storage.dart';
Set up Cloud Storage
Run
Note: Alternatively to updating your config file, you can explicitlyspecify the bucket name when you create an instance offlutterfire configurefrom your Flutter project directory. Thisupdates the Firebase config file (firebase_options.dart) in your app'scodebase so that it has the name of your defaultCloud Storage bucket.FirebaseStorage(see next step). You can find the bucket name in theCloud StorageFiles tab of theFirebase console.Access your Cloud Storage bucket by creating an instance of
FirebaseStorage:finalstorage=FirebaseStorage.instance;// Alternatively, explicitly specify the bucket name URL.// final storage = FirebaseStorage.instanceFor(bucket: "gs://<var>BUCKET_NAME</var>");
You're ready to start using Cloud Storage!
Next step? Learn how tocreate a Cloud Storage reference.
Advanced setup
There are a few use cases that require additional setup:
- Using Cloud Storage buckets inmultiple geographic regions
- Using Cloud Storage buckets indifferent storage classes
- Using Cloud Storage buckets with multiple authenticated users in the same app
The first use case is perfect if you have users across the world, and want tostore their data near them. For instance, 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 instance: 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 multiple Cloud 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 multiple Cloud Storage buckets
If you want to use a Cloud Storage bucket other than the default provided above,or use multiple Cloud Storage buckets in a single app, you can create an instanceofFirebaseStorage that references your custom bucket:
// Get a non-default Storage bucketfinalstorage=FirebaseStorage.instanceFor(bucket:"gs://my-custom-bucket");Working with imported buckets
When importing an existing Cloud Storage bucket into Firebase, you'llhave to grant Firebase the ability to access these files using thegsutil tool, included in theGoogle Cloud SDK:
gsutil-maclch-r-uservice-PROJECT_NUMBER@gcp-sa-firebasestorage.iam.gserviceaccount.comgs://YOUR-CLOUD-STORAGE-BUCKETYou can find your project number as described in theintroduction toFirebase 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:
// Use a non-default Appfinalstorage=FirebaseStorage.instanceFor(app:customApp);Next steps
- Prepare to launch your app:
- EnableApp Check to help ensure that onlyyour apps can access your storage buckets.
- Set upbudget alertsfor your project in the Google Cloud Console.
- Monitor theUsage and billing dashboardin the Firebase console to get an overall picture of your project'susage across multiple Firebase services. You can also visit theCloud StorageUsage dashboard for moredetailed usage information.
- Review theFirebase launch checklist.
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-03 UTC.