Get Started with Firebase Storage for C++

Firebase Storage lets you upload and share user generated content, such as images and video, which allows you to build rich media content into your apps. Firebase Storage stores this data in a Google Cloud Storage bucket, a petabyte scale object storage solution with high availability and global redundancy. Firebase Storage lets you securely upload these files directly from mobile devices and web browsers, handling spotty networks with ease.

Before you begin

Android

  1. If you haven't yet connected your app to your Firebase project, do so from the Firebase console.
  2. Add Firebase to your Android project.
  3. Add the dependency for Firebase Storage to your app-level build.gradle file:
    dependencies {
         compile 'com.google.firebase:firebase-storage:10.0.1'
    }
  4. Link the libapp.a and libstorage.a static library, from the C++ SDK.

iOS

  1. If you haven't yet connected your app to your Firebase project, do so from the Firebase console.
  2. Add Firebase to your iOS project.
  3. Include the following Pod in your Podfile:
    pod 'Firebase/Storage'
  4. Run pod install
  5. Add firebase.framework and firebase_storage.framework, from the C++ SDK, to your Xcode project.

Setting up public access

Storage provides a declarative rules language that allows you to define how your data should be structured, how it should be indexed, and when your data can be read from and written to. By default, read and write access to Storage is restricted so only authenticated users can read or write data. To get started without setting up Authentication, you can configure your rules for public access. This does make Storage open to anyone, even people not using your app, so be sure to restrict your Storage again when you set up authentication.

Create and initialize firebase::App

Before you can access the Storage, you'll need to create and initialize the firebase::App.

Include the header file for firebase::App:

#include "firebase/app.h"

Android

Create the firebase::App, passing the JNI environment and a jobject reference to the Java Activity as arguments:

app = App::Create(AppOptions(), jni_env, activity);

iOS

Create the firebase::App:

app = App::Create(AppOptions());

Access the firebase::storage::Storage class

The firebase::storage::Storage is the entry point for the Firebase Storage C++ SDK.

Storage* storage = Storage::GetInstance(app);

If you have chosen to use public access for your rules, you can proceed to the sections on saving and retrieving data.

Setting up restricted access.

If you do not want to use public access you can add Firebase Authentication to your app to control access to Firebase Storage.

Next Steps

You're ready to start using Firebase Storage! First, let's learn how to create a Firebase Storage reference.

Send feedback about...

Need help? Visit our support page.