Cloud Storage for Firebase 可讓您上傳及分享使用者原創內容,例如圖片和影片,在應用程式中建構多媒體內容。您的資料會儲存在 Google Cloud Storage 值區中,這是具備高可用性和全域備援機制的 Exabyte 級物件儲存空間解決方案。Cloud Storage for Firebase 可讓您直接從行動裝置和網路瀏覽器安全上傳這些檔案,輕鬆處理網路不穩定的情況。
// Get the default bucket from a custom FirebaseAppFirebaseStoragestorage=FirebaseStorage.GetInstance(customApp);// Get a non-default bucket from a custom FirebaseAppFirebaseStoragestorageCustom=FirebaseStorage.GetInstance(customApp,"gs://my-custom-bucket");
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-03 (世界標準時間)。"],[],[],null,["\u003cbr /\u003e\n\nCloud Storage for Firebase lets you upload and share user generated content, such\nas images and video, which allows you to build rich media content into your\napps. Your data is stored in a\n[Google Cloud Storage](//cloud.google.com/storage) bucket --- an\nexabyte scale object storage solution with high availability and global\nredundancy. Cloud Storage for Firebase lets you securely upload these files\ndirectly from mobile devices and web browsers, handling spotty networks with\nease.\n\nBefore you begin\n\nBefore you can use\n[Cloud Storage](/docs/reference/unity/namespace/firebase/storage),\nyou need to:\n\n- Register your Unity project and configure it to use Firebase.\n\n - If your Unity project already uses Firebase, then it's already\n registered and configured for Firebase.\n\n - If you don't have a Unity project, you can download a\n [sample app](//github.com/google/mechahamster).\n\n- Add the [Firebase Unity SDK](/download/unity) (specifically, `FirebaseStorage.unitypackage`) to\n your Unity project.\n\n| **Find detailed instructions for these initial\n| setup tasks in\n| [Add Firebase to your Unity project](/docs/unity/setup#prerequisites).**\n\nNote that adding Firebase to your Unity project involves tasks both in the\n[Firebase console](//console.firebase.google.com/) and in your open Unity project\n(for example, you download Firebase config files from the console, then move\nthem into your Unity project).\n\nAlso, make sure your Firebase project is on the [pay-as-you-go Blaze pricing plan](/pricing). If\nyou're new to Firebase and Google Cloud, check if you're eligible for a\n[$300 credit](/support/faq#pricing-free-trial).\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\nCreate a default Cloud Storage bucket\n\n1. From the navigation pane of the [Firebase console](//console.firebase.google.com/), select **Storage**.\n\n If your project is not yet on the pay-as-you-go Blaze pricing plan, then you'll be\n prompted to upgrade your project.\n2. Click **Get started**.\n\n3. Select a [location](/docs/storage/locations) for your default bucket.\n\n - Buckets in `US-CENTRAL1`, `US-EAST1`, and `US-WEST1` can take advantage of the\n [\"Always Free\" tier](https://cloud.google.com/storage/pricing#cloud-storage-always-free) for Google Cloud Storage.\n Buckets in all other locations follow\n [Google Cloud Storage pricing and usage](https://cloud.google.com/storage/pricing).\n\n - If you'd like, you can later\n [create multiple buckets](#use_multiple_storage_buckets), each with its\n own location.\n\n4. Configure the Firebase Security Rules for your default bucket. During development,\n consider [setting up your rules for public access](#set_up_public_access).\n\n5. Click **Done**.\n\nYou can now view the bucket in the\n[Cloud Storage *Files* tab](https://console.firebase.google.com/project/_/storage/)\nof the Firebase console. Your default bucket name format is\n\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.firebasestorage.app`.\n| **Note:** Starting October 30, 2024, all new default Cloud Storage buckets have the name format \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.firebasestorage.app`. Any default buckets created *before* that date have the name format \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.appspot.com`. Learn more in the [FAQs](/docs/storage/faqs-storage-changes-announced-sept-2024#all-changes-default-storage-bucket).\n\nSet up public access\n\nCloud Storage for Firebase provides a declarative rules language that allows you\nto define how your data should be structured, how it should be indexed, and when\nyour data can be read from and written to. By default, read and write access to\nCloud Storage is restricted so only authenticated users can read or write\ndata. To get started without setting up [Authentication](/docs/auth), you can\n[configure your rules for public access](/docs/storage/security/rules-conditions#public).\n\nThis does make Cloud Storage open to anyone, even people not using your\napp, so be sure to restrict your Cloud Storage again when you set up\nauthentication.\n\nAccess the `FirebaseStorage` class\n\nThe [`Firebase.Storage.FirebaseStorage`](/docs/reference/unity/class/firebase/storage/firebase-storage)\nis the entry point for the Cloud Storage Unity SDK. \n\n```c#\n// Get a reference to the storage service, using the default Firebase App\nFirebaseStorage storage = FirebaseStorage.DefaultInstance;\n```\n\nYou're ready to start using Cloud Storage!\n\nNext step? Learn how to\n[create a Cloud Storage reference](/docs/storage/unity/create-reference).\n\nAdvanced setup\n\nThere are a few use cases that require additional setup:\n\n- Using Cloud Storage buckets in [multiple geographic regions](//cloud.google.com/storage/docs/bucket-locations)\n- Using Cloud Storage buckets in [different storage classes](//cloud.google.com/storage/docs/storage-classes)\n- Using Cloud Storage buckets with multiple authenticated users in the same app\n\nThe first use case is perfect if you have users across the world, and want to\nstore their data near them. For instance, you can create buckets in the US,\nEurope, and Asia to store data for users in those regions to reduce latency.\n\nThe second use case is helpful if you have data with different access patterns.\nFor instance: you can set up a multi-regional or regional bucket that stores\npictures or other frequently accessed content, and a nearline or coldline bucket\nthat stores user backups or other infrequently accessed content.\n\nIn either of these use cases, you'll want to\n[use multiple Cloud Storage buckets](/docs/storage/unity/start#use_multiple_storage_buckets).\n\nThe third use case is useful if you're building an app, like Google Drive, which\nlets users have multiple logged in accounts (for instance, a personal account\nand a work account). You can [use a custom Firebase App](/docs/storage/unity/start#use_a_custom_firebaseapp)\ninstance to authenticate each additional account.\n\nUse multiple Cloud Storage buckets\n\nIf you want to use a Cloud Storage bucket other than the default provided above,\nor use multiple Cloud Storage buckets in a single app, you can create an instance\nof `FirebaseStorage` that references your custom bucket: \n\n```c#\n// Get a non-default Storage bucket\nvar storage = FirebaseStorage.GetInstance(\"gs://my-custom-bucket\");\n```\n\nWorking with imported buckets\n\nWhen importing an existing Cloud Storage bucket into Firebase, you'll\nhave to grant Firebase the ability to access these files using the\n`gsutil` tool, included in the\n[Google Cloud SDK](//cloud.google.com/sdk/docs/): \n\n```\ngsutil -m acl ch -r -u service-PROJECT_NUMBER@gcp-sa-firebasestorage.iam.gserviceaccount.com gs://BUCKET_NAME\n```\n\nYou can find your project number as described in the\n[introduction to Firebase projects](/docs/projects/learn-more#project-number).\n\nThis does not affect newly created buckets, as those have the default access\ncontrol set to allow Firebase. This is a temporary measure, and will be\nperformed automatically in the future.\n\nUse a custom Firebase App\n\nIf you're building a more complicated app using a custom `FirebaseApp`, you\ncan create an instance of `FirebaseStorage` initialized with that\napp: \n\n```c#\n// Get the default bucket from a custom FirebaseApp\nFirebaseStorage storage = FirebaseStorage.GetInstance(customApp);\n\n// Get a non-default bucket from a custom FirebaseApp\nFirebaseStorage storageCustom = FirebaseStorage.GetInstance(customApp, \"gs://my-custom-bucket\");\n```\n\nNext steps\n\n- Prepare to launch your app:\n\n\n - Set up [budget\n alerts](/docs/projects/billing/avoid-surprise-bills#set-up-budget-alert-emails) for your project in the Google Cloud console.\n - Monitor the [*Usage and billing*\n dashboard](//console.firebase.google.com/project/_/usage) in the Firebase console to get an overall picture of your project's usage across multiple Firebase services. You can also visit the [Cloud Storage *Usage*\n dashboard](//console.firebase.google.com/project/_/storage/usage) for more detailed usage information.\n - Review the [Firebase launch checklist](/support/guides/launch-checklist)."]]