Go to console

Introduction to the Admin Cloud Storage API

Cloud Storage for Firebase stores your data in Google Cloud Storage, an exabyte scale object storage solution with high availability and global redundancy. Firebase Admin SDK allows you to directly access your Google Cloud Storage buckets from privileged environments. Then you can use Google Cloud Storage APIs to manipulate the objects stored in the buckets.

Use a default bucket

You can specify a default bucket name when initializing the Admin SDK. Then you can retrieve an authenticated reference to this bucket. The bucket name must not contain gs:// or any other protocol prefixes. For example, if the bucket URL displayed in the Firebase Console is gs://bucket-name.appspot.com, pass the string bucket-name.appspot.com to the Admin SDK.


var admin = require("firebase-admin");

var serviceAccount = require("path/to/serviceAccountKey.json");

    credential: admin.credential.cert(serviceAccount),
    storageBucket: "<BUCKET_NAME>.appspot.com"

var bucket = admin.storage().bucket();

// 'bucket' is an object defined in the @google-cloud/storage library.
// See https://googlecloudplatform.github.io/google-cloud-node/#/docs/storage/latest/storage/bucket
// for more details.


FileInputStream serviceAccount = new FileInputStream("path/to/serviceAccountKey.json");

FirebaseOptions options = new FirebaseOptions.Builder()

Bucket bucket = StorageClient.getInstance().bucket();

// 'bucket' is an object defined in the google-cloud-storage Java library.
// See http://googlecloudplatform.github.io/google-cloud-java/latest/apidocs/com/google/cloud/storage/Bucket.html
// for more details.


import firebase_admin
from firebase_admin import credentials
from firebase_admin import storage

cred = credentials.Certificate('path/to/serviceAccountKey.json')
firebase_admin.initialize_app(cred, {
    'storageBucket': '<BUCKET_NAME>.appspot.com'

bucket = storage.bucket()

# 'bucket' is an object defined in the google-cloud-storage Python library.
# See https://googlecloudplatform.github.io/google-cloud-python/latest/storage/buckets.html
# for more details.


import (

	firebase "firebase.google.com/go"

config := &firebase.Config{
	StorageBucket: "<BUCKET_NAME>.appspot.com",
opt := option.WithCredentialsFile("path/to/serviceAccountKey.json")
app, err := firebase.NewApp(context.Background(), config, opt)
if err != nil {

client, err := app.Storage(context.Background())
if err != nil {

bucket, err := client.DefaultBucket()
if err != nil {
// 'bucket' is an object defined in the cloud.google.com/go/storage package.
// See https://godoc.org/cloud.google.com/go/storage#BucketHandle
// for more details.

You can use the bucket references returned by the Admin SDK in conjunction with the official Google Cloud Storage client libraries to upload, download, and modify content in the buckets associated with your Firebase projects. Note that you do not have to authenticate Google Cloud Storage libraries when using the Firebase Admin SDK. The bucket references returned by the Admin SDK are already authenticated with the credentials used to initialize your Firebase app.

Use custom buckets

If you want to use a storage bucket other than the default provided above, or use multiple storage buckets in a single app, you can retrieve a reference to a custom bucket as shown below:


var bucket = admin.storage().bucket("my-custom-bucket");


Bucket bucket = StorageClient.getInstance().bucket("my-custom-bucket");


bucket = storage.bucket('my-custom-bucket')


 bucket, err := client.Bucket("my-custom-bucket")

Use a custom Firebase app

If you are building a more complicated application that interacts with multiple Firebase apps, you can access the storage buckets associated with a specific Firebase app as follows:


var bucket = customApp.storage().bucket();


Bucket bucket = StorageClient.getInstance(customApp).bucket();


bucket = storage.bucket(app=custom_app)


otherClient, err := otherApp.Storage(context.Background())
bucket, err := otherClient.Bucket("other-app-bucket")

Google Cloud Storage client libraries

Firebase Admin SDK depends on the Google Cloud Storage client libraries to provide Cloud Storage access. The bucket references returned by the Admin SDK are objects defined in these libraries. Please refer to the documentation and API references of the Google Cloud Storage client libraries to learn how to use the returned bucket references in use cases like file upload and download.