Cloud Storage for Firebase는 고가용성과 글로벌 중복성을 갖춘 엑사바이트급 객체 스토리지 솔루션인 Google Cloud Storage 버킷에 데이터를 저장합니다. Firebase Admin SDK를 사용하면 권한이 있는 환경에서 Cloud Storage 버킷에 직접 액세스할 수 있습니다. 그런 다음 Google Cloud Storage API를 사용하여 버킷에 저장된 객체를 조작할 수 있습니다.
Admin SDK를 사용하면 사용자가 버킷의 객체를 다운로드할 수 있도록 공유 가능한 URL을 만들 수도 있습니다.
기본 버킷 사용
Admin SDK를 초기화할 때 기본 버킷 이름을 지정할 수 있습니다. 그런 다음 이 버킷에 대한 인증된 참조를 가져올 수 있습니다.
버킷 이름에 gs:// 또는 다른 프로토콜 프리픽스를 포함해서는 안 됩니다.
예를 들어 Firebase Console에 표시되는 버킷 URL이 gs://PROJECT_ID.firebasestorage.app이면 PROJECT_ID.firebasestorage.app 문자열을 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.
자바
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.
Admin SDK에서 반환한 버킷 참조를 공식 Google Cloud Storage 클라이언트 라이브러리와 함께 사용하여 Firebase 프로젝트에 연결된 버킷의 콘텐츠를 업로드, 다운로드, 수정할 수 있습니다. Firebase Admin SDK를 사용할 때는 Google Cloud Storage 라이브러리를 인증할 필요가 없습니다. Admin SDK에서 반환하는 버킷 참조는 Firebase 앱 초기화에 사용된 사용자 인증 정보로 이미 인증되어 있습니다.
커스텀 버킷 사용
이 가이드 앞부분에서 설명한 기본 버킷 이외의 Cloud Storage 버킷을 사용하거나 단일 앱에서 Cloud Storage 버킷 여러 개를 사용하려는 경우 커스텀 버킷에 대한 참조를 가져올 수 있습니다.
Firebase Admin SDK는 Google Cloud Storage 클라이언트 라이브러리를 통해 Cloud Storage 액세스를 제공합니다. Admin SDK에서 반환하는 버킷 참조는 이러한 라이브러리에 정의된 객체입니다. 파일 업로드 및 다운로드와 같은 사용 사례에서 반환된 버킷 참조를 사용하는 방법은 Google Cloud Storage 클라이언트 라이브러리의 문서 및 API 참조를 확인하세요.
[null,null,["최종 업데이트: 2025-08-27(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)."]]