Stay organized with collections
Save and categorize content based on your preferences.
Cloud Storage for Firebase stores your data in a
Google Cloud Storage bucket — an
exabyte scale object storage solution with high availability and global
redundancy. The Firebase Admin SDK allows you to directly access your
Cloud Storage buckets from privileged environments. Then you can use
Google Cloud Storage APIs
to manipulate the objects stored in the buckets.
The Admin SDK also lets you to create shareable URLs so users can
download objects in your 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://PROJECT_ID.firebasestorage.app, pass the string
PROJECT_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 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 Cloud Storage bucket other than the default bucket
described earlier in this guide, or use multiple Cloud Storage buckets in
a single app, you can retrieve a reference to a custom bucket:
If you are building a more complicated application that interacts with
multiple Firebase apps, you can
access the Cloud Storage buckets associated with a specific Firebase app
as follows:
You can use the Admin SDK to generate a non-expiring download URL for
files stored in your buckets. Anyone with this URL can permanently
access the file.
The Firebase Admin SDKs depend 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. 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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["\u003cbr /\u003e\n\nCloud Storage for Firebase stores your data in a\n[Google Cloud Storage](//cloud.google.com/storage) bucket --- an\nexabyte scale object storage solution with high availability and global\nredundancy. The Firebase Admin SDK allows you to directly access your\nCloud Storage buckets from privileged environments. Then you can use\n[Google Cloud Storage APIs](//cloud.google.com/storage/docs/reference/libraries)\nto manipulate the objects stored in the buckets.\n\nThe Admin SDK also lets you to create shareable URLs so users can\ndownload objects in your buckets.\n| **Important** : The following changes to pricing plan requirements are happening for Cloud Storage for Firebase. Learn more in the [FAQs](/docs/storage/faqs-storage-changes-announced-sept-2024).\n|\n| - **Starting\n| October 30, 2024** , your Firebase project must be on the [pay-as-you-go Blaze pricing plan](/pricing) to provision a new Cloud Storage for Firebase default bucket. The bucket can optionally use the [\"Always Free\" tier](https://cloud.google.com/storage/pricing#cloud-storage-always-free) for Google Cloud Storage.\n| - **Starting\n| October 1, 2025** , your Firebase project must be on the [pay-as-you-go Blaze pricing plan](/pricing) to maintain access to your default bucket and all other Cloud Storage resources. Any `*.appspot.com` default bucket will maintain its current no-cost level of usage even on the Blaze pricing plan.\n\nUse a default bucket\n\nYou can specify a default bucket name when initializing the Admin SDK. Then you\ncan retrieve an authenticated reference to this bucket.\n\nThe bucket name must *not* contain `gs://` or any other protocol prefixes.\nFor example, if the bucket URL displayed in the\n[Firebase console](//console.firebase.google.com/project/_/storage)\nis `gs://`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.firebasestorage.app`, pass the string\n\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.firebasestorage.app` to the Admin SDK. \n\nNode.js \n\n const { initializeApp, cert } = require('firebase-admin/app');\n const { getStorage } = require('firebase-admin/storage');\n\n const serviceAccount = require('./path/to/serviceAccountKey.json');\n\n initializeApp({\n credential: cert(serviceAccount),\n storageBucket: '\u003cBUCKET_NAME\u003e.appspot.com'\n });\n\n const bucket = getStorage().bucket();\n\n // 'bucket' is an object defined in the @google-cloud/storage library.\n // See https://googlecloudplatform.github.io/google-cloud-node/#/docs/storage/latest/storage/bucket\n // for more details.\n\nJava \n\n FileInputStream serviceAccount = new FileInputStream(\"path/to/serviceAccountKey.json\");\n\n FirebaseOptions options = FirebaseOptions.builder()\n .setCredentials(GoogleCredentials.fromStream(serviceAccount))\n .setStorageBucket(\"\u003cBUCKET_NAME\u003e.appspot.com\")\n .build();\n FirebaseApp.initializeApp(options);\n\n Bucket bucket = StorageClient.getInstance().bucket();\n\n // 'bucket' is an object defined in the google-cloud-storage Java library.\n // See https://cloud.google.com/java/docs/reference/google-cloud-storage/latest/com.google.cloud.storage.Bucket\n // for more details.\n\nPython \n\n import firebase_admin\n from firebase_admin import credentials\n from firebase_admin import storage\n\n cred = credentials.Certificate('path/to/serviceAccountKey.json')\n firebase_admin.initialize_app(cred, {\n 'storageBucket': '\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e.firebasestorage.app'\n })\n\n bucket = storage.bucket()\n\n # 'bucket' is an object defined in the google-cloud-storage Python library.\n # See https://googlecloudplatform.github.io/google-cloud-python/latest/storage/buckets.html\n # for more details.\n\nGo \n\n import (\n \t\"context\"\n \t\"log\"\n\n \tfirebase \"firebase.google.com/go/v4\"\n \t\"firebase.google.com/go/v4/auth\"\n \t\"google.golang.org/api/option\"\n )\n\n config := &firebase.Config{\n \tStorageBucket: \"\u003cBUCKET_NAME\u003e.appspot.com\",\n }\n opt := option.WithCredentialsFile(\"path/to/serviceAccountKey.json\")\n app, err := firebase.NewApp(context.Background(), config, opt)\n if err != nil {\n \tlog.Fatalln(err)\n }\n\n client, err := app.Storage(context.Background())\n if err != nil {\n \tlog.Fatalln(err)\n }\n\n bucket, err := client.DefaultBucket()\n if err != nil {\n \tlog.Fatalln(err)\n }\n // 'bucket' is an object defined in the cloud.google.com/go/storage package.\n // See https://godoc.org/cloud.google.com/go/storage#BucketHandle\n // for more details. \n https://github.com/firebase/firebase-admin-go/blob/26dec0b7589ef7641eefd6681981024079b8524c/snippets/storage.go#L31-L51\n\nYou can use the bucket references returned by the Admin SDK in conjunction with\nthe official\n[Google Cloud Storage client libraries](//cloud.google.com/storage/docs/reference/libraries)\nto upload, download, and modify content in the buckets associated with your\nFirebase projects. Note that you do not have to authenticate\nGoogle Cloud Storage libraries when using the Firebase Admin SDK. The bucket\nreferences returned by the Admin SDK are already authenticated with the\ncredentials used to initialize your Firebase app.\n\nUse custom buckets\n\nIf you want to use a Cloud Storage bucket other than the default bucket\ndescribed earlier in this guide, or use multiple Cloud Storage buckets in\na single app, you can retrieve a reference to a custom bucket: \n\nNode.js \n\n const bucket = getStorage().bucket('my-custom-bucket');\n\nJava \n\n Bucket bucket = StorageClient.getInstance().bucket(\"my-custom-bucket\");\n\nPython \n\n bucket = storage.bucket('my-custom-bucket')\n\nGo \n\n bucket, err := client.Bucket(\"my-custom-bucket\") \n https://github.com/firebase/firebase-admin-go/blob/26dec0b7589ef7641eefd6681981024079b8524c/snippets/storage.go#L64-L64\n\nUse a custom Firebase app\n\nIf you are building a more complicated application that interacts with\n[multiple Firebase apps](/docs/admin/setup#initialize-multiple-apps), you can\naccess the Cloud Storage buckets associated with a specific Firebase app\nas follows: \n\nNode.js \n\n const bucket = getStorage(customApp).bucket();\n\nJava \n\n Bucket bucket = StorageClient.getInstance(customApp).bucket();\n\nPython \n\n bucket = storage.bucket(app=custom_app)\n\nGo \n\n otherClient, err := otherApp.Storage(context.Background())\n bucket, err := otherClient.Bucket(\"other-app-bucket\")\n\nGet a shareable download URL\n\nYou can use the Admin SDK to generate a non-expiring download URL for\nfiles stored in your buckets. Anyone with this URL can permanently\naccess the file. \n\nNode.js \n\n const { getStorage, getDownloadURL } = require('firebase-admin/storage');\n\n const fileRef = getStorage().bucket('my-bucket').file('my-file');\n const downloadURL= await getDownloadURL(fileRef);\n\nGoogle Cloud Storage client libraries\n\nThe Firebase Admin SDKs depend on the\n[Google Cloud Storage client libraries](//cloud.google.com/storage/docs/reference/libraries)\nto provide Cloud Storage access. The bucket references returned by the\nAdmin SDK are objects defined in these libraries. Refer to the documentation and\nAPI references of the Google Cloud Storage client libraries to learn how to\nuse the returned bucket references in use cases like file\n[upload](//cloud.google.com/storage/docs/uploading-objects) and\n[download](//cloud.google.com/storage/docs/downloading-objects)."]]