Introduction to the Admin Cloud Storage API

Cloud Storage for Firebase stores your data in aGoogle Cloud Storage bucket — anexabyte scale object storage solution with high availability and globalredundancy. The Firebase Admin SDK allows you to directly access yourCloud Storage buckets from privileged environments. Then you can useGoogle Cloud Storage APIs to manipulate the objects stored in the buckets.

TheAdmin SDK also lets you to create shareable URLs so users candownload objects in your buckets.

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.

Use a default bucket

You can specify a default bucket name when initializing the Admin SDK. Then youcan retrieve an authenticated reference to this bucket.

The bucket name mustnot contaings:// or any other protocol prefixes.For example, if the bucket URL displayed in theFirebase console isgs://PROJECT_ID.firebasestorage.app, pass the stringPROJECT_ID.firebasestorage.app to the Admin SDK.

Node.js

const{initializeApp,cert}=require('firebase-admin/app');const{getStorage}=require('firebase-admin/storage');constserviceAccount=require('./path/to/serviceAccountKey.json');initializeApp({credential:cert(serviceAccount),storageBucket:'<BUCKET_NAME>.appspot.com'});constbucket=getStorage().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.

Java

FileInputStreamserviceAccount=newFileInputStream("path/to/serviceAccountKey.json");FirebaseOptionsoptions=FirebaseOptions.builder().setCredentials(GoogleCredentials.fromStream(serviceAccount)).setStorageBucket("<BUCKET_NAME>.appspot.com").build();FirebaseApp.initializeApp(options);Bucketbucket=StorageClient.getInstance().bucket();// 'bucket' is an object defined in the google-cloud-storage Java library.// See https://cloud.google.com/java/docs/reference/google-cloud-storage/latest/com.google.cloud.storage.Bucket// for more details.

Python

importfirebase_adminfromfirebase_adminimportcredentialsfromfirebase_adminimportstoragecred=credentials.Certificate('path/to/serviceAccountKey.json')firebase_admin.initialize_app(cred,{'storageBucket':'PROJECT_ID.firebasestorage.app'})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.

Go

import("context""log"firebase"firebase.google.com/go/v4""firebase.google.com/go/v4/auth""google.golang.org/api/option")config:=&firebase.Config{StorageBucket:"<BUCKET_NAME>.appspot.com",}opt:=option.WithCredentialsFile("path/to/serviceAccountKey.json")app,err:=firebase.NewApp(context.Background(),config,opt)iferr!=nil{log.Fatalln(err)}client,err:=app.Storage(context.Background())iferr!=nil{log.Fatalln(err)}bucket,err:=client.DefaultBucket()iferr!=nil{log.Fatalln(err)}// '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 withthe officialGoogle Cloud Storage client libraries to upload, download, and modify content in the buckets associated with yourFirebase projects. Note that you do not have to authenticateGoogle Cloud Storage libraries when using the Firebase Admin SDK. The bucketreferences returned by the Admin SDK are already authenticated with thecredentials used to initialize your Firebase app.

Use custom buckets

If you want to use aCloud Storage bucket other than the default bucketdescribed earlier in this guide, or use multipleCloud Storage buckets ina single app, you can retrieve a reference to a custom bucket:

Node.js

constbucket=getStorage().bucket('my-custom-bucket');

Java

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

Python

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

Go

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

Use a custom Firebase app

If you are building a more complicated application that interacts withmultiple Firebase apps, you canaccess theCloud Storage buckets associated with a specific Firebase appas follows:

Node.js

constbucket=getStorage(customApp).bucket();

Java

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

Python

bucket=storage.bucket(app=custom_app)

Go

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

Get a shareable download URL

You can use theAdmin SDK to generate a non-expiring download URL forfiles stored in your buckets. Anyone with this URL can permanentlyaccess the file.

Node.js

const{getStorage,getDownloadURL}=require('firebase-admin/storage');constfileRef=getStorage().bucket('my-bucket').file('my-file');constdownloadURL=awaitgetDownloadURL(fileRef);

Google Cloud Storage client libraries

The Firebase Admin SDKs depend on theGoogle Cloud Storage client libraries to provideCloud Storage access. The bucket references returned by theAdmin SDK are objects defined in these libraries. Refer to the documentation andAPI references of theGoogle Cloud Storage client libraries to learn how touse the returned bucket references in use cases like fileupload anddownload.

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.