firebase::storage::Storage

#include <storage.h>

Entry point for the Firebase C++ SDK for CloudStorage.

Summary

To use the SDK, callfirebase::storage::Storage::GetInstance() to obtain an instance ofStorage, then useGetReference() to obtain references to child blobs. From there you can upload data with StorageReference::PutStream(), get data via StorageReference::GetStream().

Constructors and Destructors

~Storage()
Destructor.

Public functions

GetReference() const
Get aStorageReference to the root of the database.
GetReference(const char *path) const
Get aStorageReference for the specified path.
GetReference(const std::string & path) const
Get aStorageReference for the specified path.
GetReferenceFromUrl(const char *url) const
Get aStorageReference for the provided URL.
GetReferenceFromUrl(const std::string & url) const
Get aStorageReference for the provided URL.
UseEmulator(const std::string & host, int port)
void
Configures theStorage SDK to use an emulated backend instead of the default remote backend.
UseEmulator(const char *host, int port)
void
Configures theStorage SDK to use an emulated backend instead of the default remote backend.
app()
Get the firease::App that thisStorage was created with.
max_download_retry_time()
double
Returns the maximum time in seconds to retry a download if a failure occurs.
max_operation_retry_time()
double
Returns the maximum time to retry operations other than upload and download if a failure occurs.
max_upload_retry_time()
double
Returns the maximum time to retry an upload if a failure occurs.
set_max_download_retry_time(double max_transfer_retry_seconds)
void
Sets the maximum time to retry a download if a failure occurs.
set_max_operation_retry_time(double max_transfer_retry_seconds)
void
Sets the maximum time to retry operations other than upload and download if a failure occurs.
set_max_upload_retry_time(double max_transfer_retry_seconds)
void
Sets the maximum time to retry an upload if a failure occurs.
url()
std::string
Get the URL that thisStorage was created with.

Public static functions

GetInstance(::firebase::App *app,InitResult *init_result_out)
Get an instance ofStorage corresponding to the givenApp.
GetInstance(::firebase::App *app, const char *url,InitResult *init_result_out)
Get an instance ofStorage corresponding to the givenApp, with the given CloudStorage URL.

Public functions

GetReference

StorageReferenceGetReference()const

Get aStorageReference to the root of the database.

GetReference

StorageReferenceGetReference(constchar*path)const

Get aStorageReference for the specified path.

GetReference

StorageReferenceGetReference(conststd::string&path)const

Get aStorageReference for the specified path.

GetReferenceFromUrl

StorageReferenceGetReferenceFromUrl(constchar*url)const

Get aStorageReference for the provided URL.

GetReferenceFromUrl

StorageReferenceGetReferenceFromUrl(conststd::string&url)const

Get aStorageReference for the provided URL.

UseEmulator

voidUseEmulator(conststd::string&host,intport)

Configures theStorage SDK to use an emulated backend instead of the default remote backend.

This method should be called before invoking any other methods on a new instance ofStorage

UseEmulator

voidUseEmulator(constchar*host,intport)

Configures theStorage SDK to use an emulated backend instead of the default remote backend.

This method should be called before invoking any other methods on a new instance ofStorage

app

::firebase::App*app()

Get the firease::App that thisStorage was created with.

Details
Returns
Thefirebase::App thisStorage was created with.

max_download_retry_time

doublemax_download_retry_time()

Returns the maximum time in seconds to retry a download if a failure occurs.

max_operation_retry_time

doublemax_operation_retry_time()

Returns the maximum time to retry operations other than upload and download if a failure occurs.

max_upload_retry_time

doublemax_upload_retry_time()

Returns the maximum time to retry an upload if a failure occurs.

set_max_download_retry_time

voidset_max_download_retry_time(doublemax_transfer_retry_seconds)

Sets the maximum time to retry a download if a failure occurs.

Defaults to 600 seconds (10 minutes).

set_max_operation_retry_time

voidset_max_operation_retry_time(doublemax_transfer_retry_seconds)

Sets the maximum time to retry operations other than upload and download if a failure occurs.

Defaults to 120 seconds (2 minutes).

set_max_upload_retry_time

voidset_max_upload_retry_time(doublemax_transfer_retry_seconds)

Sets the maximum time to retry an upload if a failure occurs.

Defaults to 600 seconds (10 minutes).

url

std::stringurl()

Get the URL that thisStorage was created with.

Details
Returns
The URL thisStorage was created with, or an empty string if thisStorage was created with default parameters.

~Storage

~Storage()

Destructor.

You may delete an instance ofStorage when you are finished using it, to shut down theStorage library.

Public static functions

GetInstance

Storage*GetInstance(::firebase::App*app,InitResult*init_result_out)

Get an instance ofStorage corresponding to the givenApp.

CloudStorage usesfirebase::App to communicate with Firebase Authentication to authenticate users to the server backend.

Details
Parameters
app
An instance offirebase::App. CloudStorage will use this to communicate with Firebase Authentication.
init_result_out
Optional: If provided, write the init result here. Will be set to kInitResultSuccess if initialization succeeded, or kInitResultFailedMissingDependency on Android if Google Play services is not available on the current device.
Returns
An instance ofStorage corresponding to the givenApp.

GetInstance

Storage*GetInstance(::firebase::App*app,constchar*url,InitResult*init_result_out)

Get an instance ofStorage corresponding to the givenApp, with the given CloudStorage URL.

CloudStorage usesfirebase::App to communicate with Firebase Authentication to authenticate users to the server backend.

Details
Parameters
app
An instance offirebase::App. CloudStorage will use this to communicate with Firebase Authentication.
url
CloudStorage URL.
init_result_out
Optional: If provided, write the init result here. Will be set to kInitResultSuccess if initialization succeeded, or kInitResultFailedMissingDependency on Android if Google Play services is not available on the current device.
Returns
An instance ofStorage corresponding to the givenApp.

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 2025-11-18 UTC.