Get started with Cloud Storage for C++ 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
Before you can useCloud Storage,you need to:
Register your C++ project and configure it to use Firebase.
If your C++ project already uses Firebase, then it's already registered andconfigured for Firebase.
Add theFirebaseC++ SDK to your C++ project.
Note that adding Firebase to your C++ project involves tasks both in theFirebase console and in your open C++ project (for example, you downloadFirebase config files from the console, then move them into your C++ project).
Also, 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
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 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.
Create and initializefirebase::App
Before you can accessCloud Storage, you'll need to create and initializethefirebase::App.
firebase::App once, no matter how many Firebase C++ features you use.Include the header file forfirebase::App:
#include"firebase/app.h"
Android
Create thefirebase::App, passing the JNI environment and ajobjectreference to the Java Activity as arguments:
app=App::Create(AppOptions(),jni_env,activity);
iOS+
Create thefirebase::App:
app=App::Create(AppOptions());
Access thefirebase::storage::Storage class
Thefirebase::storage::Storageclass is the entry point for theCloud Storage C++ SDK.
Storage*storage=Storage::GetInstance(app);
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:
- UsingCloud Storage buckets inmultiple geographic regions
- UsingCloud Storage buckets indifferent storage classes
- UsingCloud 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 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 provided above,or use multipleCloud Storage buckets in a single app, you can create an instanceoffirebase::storage::Storage that references your custom bucket:
// Get a non-defaultCloud Storage bucketStorage*storage=Storage::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 customfirebase::App, youcan create an instance offirebase::storage::Storage initialized with thatapp:
// Get the default bucket from a custom firebase::AppStorage*storage=Storage::GetInstance(customApp);// Get a non-default bucket from a custom firebase::AppStorage*storage=Storage::GetInstance(customApp,"gs://my-custom-bucket");
Next steps
Prepare to launch your app:
- Set upbudgetalertsfor your project in theGoogle Cloud console.
- Monitor theUsage and billingdashboard in theFirebase console to get an overall picture of your project'susage across multiple Firebase services.You can also visit theCloud StorageUsagedashboard 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-18 UTC.