تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تخزّن Cloud Storage for Firebase بياناتك في حزمة Google Cloud Storage، وهي حل لتخزين الكائنات بسعة إكسابايت مع توفّر عالٍ وتكرار عالمي. تتيح لك حزمة تطوير البرامج (SDK) للمشرفين في Firebase الوصول مباشرةً إلى حِزم
Cloud Storage من بيئات ذات امتيازات. بعد ذلك، يمكنك استخدام
واجهات برمجة التطبيقات Google Cloud Storage
للتعديل على العناصر المخزّنة في الحِزم.
تتيح لك السمة Admin SDK أيضًا إنشاء عناوين URL قابلة للمشاركة ليتمكّن المستخدمون من تنزيل العناصر في حِزمك.
استخدام حزمة تلقائية
يمكنك تحديد اسم حزمة تلقائي عند إعداد Admin SDK. بعد ذلك، يمكنك استرداد مرجع مصادق لهذا الحزمة.
يجب ألا يحتوي اسم الحزمة على gs:// أو أي بادئات بروتوكول أخرى.
على سبيل المثال، إذا كان عنوان URL الخاص بالحزمة المعروض في وحدة تحكّم Firebase هو 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.
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.
يمكنك استخدام مراجع الحِزم التي تعرضها حزمة تطوير البرامج (SDK) للمشرف جنبًا إلى جنب مع
Google Cloud Storage مكتبات البرامج الرسمية للعملاء
لتحميل المحتوى وتنزيله وتعديله في الحِزم المرتبطة بمشاريعك على
Firebase. يُرجى العِلم أنّه ليس عليك إثبات ملكية
مكتبات Google Cloud Storage عند استخدام حزمة تطوير البرامج (SDK) للمشرف في Firebase. تكون مراجع الحزمة التي تعرضها حزمة Admin SDK مصادقًا عليها مسبقًا باستخدام بيانات الاعتماد المستخدَمة لتهيئة تطبيق Firebase.
استخدام مجموعات مخصّصة
إذا أردت استخدام حزمة Cloud Storage غير الحزمة التلقائية الموضّحة سابقًا في هذا الدليل، أو استخدام حِزم Cloud Storage متعددة في تطبيق واحد، يمكنك استرداد مرجع إلى حزمة مخصّصة:
إذا كنت بصدد إنشاء تطبيق أكثر تعقيدًا يتفاعل مع تطبيقات Firebase متعددة، يمكنك الوصول إلى حِزم Cloud Storage المرتبطة بتطبيق Firebase معيّن على النحو التالي:
يمكنك استخدام Admin SDK لإنشاء عنوان URL صالح للتنزيل وغير قابل للانتهاء للملفات المخزّنة في حِزمك. يمكن لأي شخص لديه عنوان URL هذا الوصول إلى الملف بشكل دائم.
تعتمد حِزم Firebase Admin SDK على
Google Cloud Storage مكتبات العملاء
لتوفير إذن الوصول Cloud Storage. إنّ مراجع الحزمة التي تعرضها حزمة تطوير البرامج (SDK) الخاصة بالمشرفين هي عناصر محدّدة في هذه المكتبات. يمكنك الرجوع إلى المستندات ومراجع واجهة برمجة التطبيقات الخاصة بمكتبات برامج Google Cloud Storage لمعرفة كيفية استخدام مراجع الحِزم التي تم إرجاعها في حالات الاستخدام، مثل تحميل الملفات وتنزيلها.
تاريخ التعديل الأخير: 2025-08-01 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-01 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],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)."]]