با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Cloud Storage برای Firebase به شما امکان میدهد محتوای تولید شده توسط کاربر، مانند تصاویر و ویدیو را آپلود و به اشتراک بگذارید، که به شما امکان میدهد محتوای رسانهای غنی را در برنامههای خود بسازید. دادههای شما در یک سطل Google Cloud Storage - یک راهحل ذخیرهسازی شی در مقیاس اگزابایت با در دسترس بودن بالا و افزونگی جهانی ذخیره میشود. Cloud Storage for Firebase به شما امکان میدهد این فایلها را مستقیماً از دستگاههای تلفن همراه و مرورگرهای وب بهطور ایمن آپلود کنید و به راحتی شبکههای ناقص را مدیریت کنید.
مطمئن شوید که پروژه Firebase شما در برنامه قیمتگذاری Blaze است. اگر در Firebase و Google Cloud تازه کار هستید، بررسی کنید که آیا واجد شرایط دریافت اعتبار 300 دلاری هستید یا خیر.
اکنون می توانید سطل را در برگه Cloud StorageFiles کنسول Firebase مشاهده کنید. فرمت نام سطل پیش فرض شما این استPROJECT_ID .firebasestorage.app .
دسترسی عمومی را تنظیم کنید
Cloud Storage برای Firebase یک زبان قواعد اعلامی ارائه میکند که به شما امکان میدهد نحوه ساختار دادههایتان، نحوه فهرستبندی و زمان خواندن و نوشتن دادههایتان را تعریف کنید. به طور پیشفرض، دسترسی خواندن و نوشتن به فضای ذخیرهسازی ابری محدود شده است، بنابراین فقط کاربران تأیید شده میتوانند دادهها را بخوانند یا بنویسند. برای شروع بدون تنظیم Firebase Authentication ، می توانید قوانین خود را برای دسترسی عمومی پیکربندی کنید .
این باعث میشود که فضای ذخیرهسازی ابری برای هر کسی باز شود، حتی افرادی که از برنامه شما استفاده نمیکنند، بنابراین هنگام تنظیم احراز هویت، مطمئن شوید که فضای ذخیرهسازی ابری خود را دوباره محدود کنید.
Cloud Storage SDK را به برنامه خود اضافه کنید
از ریشه پروژه Flutter خود، دستور زیر را برای نصب افزونه اجرا کنید:
flutterfire configure از دایرکتوری پروژه Flutter خود اجرا کنید. این فایل پیکربندی Firebase ( firebase_options.dart ) را در پایگاه کد برنامه شما بهروزرسانی میکند تا نام سطل Cloud Storage پیشفرض شما را داشته باشد.
با ایجاد نمونه ای از FirebaseStorage به سطل فضای ذخیره سازی ابری خود دسترسی پیدا کنید:
finalstorage=FirebaseStorage.instance;// Alternatively, explicitly specify the bucket name URL.// final storage = FirebaseStorage.instanceFor(bucket: "gs://<var>BUCKET_NAME</var>");
شما آماده شروع استفاده از فضای ذخیرهسازی ابری هستید!
استفاده از سطلهای ذخیرهسازی ابری با چندین کاربر احراز هویت شده در یک برنامه
اولین مورد استفاده اگر کاربرانی در سراسر جهان دارید و می خواهید داده های آنها را در نزدیکی آنها ذخیره کنید، عالی است. برای مثال، میتوانید در ایالات متحده، اروپا و آسیا سطلهایی ایجاد کنید تا دادهها را برای کاربران آن مناطق ذخیره کنید تا تأخیر را کاهش دهید.
مورد دوم اگر داده هایی با الگوهای دسترسی متفاوت دارید مفید است. به عنوان مثال: میتوانید یک سطل چند منطقهای یا منطقهای راهاندازی کنید که تصاویر یا سایر محتوایی که اغلب به آنها دسترسی دارند را ذخیره میکند، و یک سطل نزدیک یا سرد که پشتیبانگیریهای کاربر یا سایر محتوایی که بهندرت به آنها دسترسی دارند را ذخیره میکند.
اگر میخواهید از یک سطل فضای ذخیرهسازی ابری غیر از سطل پیشفرض ارائهشده در بالا استفاده کنید، یا از چند سطل فضای ذخیرهسازی ابری در یک برنامه استفاده کنید، میتوانید نمونهای از FirebaseStorage ایجاد کنید که به سطل سفارشی شما ارجاع دهد:
// Get a non-default Storage bucketfinalstorage=FirebaseStorage.instanceFor(bucket:"gs://my-custom-bucket");
کار با سطل های وارداتی
هنگام وارد کردن یک سطل فضای ذخیره سازی ابری موجود به Firebase، باید به Firebase امکان دسترسی به این فایل ها را با استفاده از ابزار gsutil موجود در Google Cloud SDK بدهید:
می توانید شماره پروژه خود را همانطور که در مقدمه پروژه های Firebase توضیح داده شده است، پیدا کنید.
این روی سطلهای تازه ایجاد شده تأثیری نمیگذارد، زیرا آنها دارای تنظیم پیشفرض کنترل دسترسی برای اجازه دادن به Firebase هستند. این یک اقدام موقت است و در آینده به صورت خودکار انجام خواهد شد.
از یک برنامه Firebase سفارشی استفاده کنید
اگر با استفاده از FirebaseApp سفارشی برنامه پیچیدهتری میسازید، میتوانید یک نمونه از FirebaseStorage که با آن برنامه مقداردهی شده است ایجاد کنید:
// Use a non-default Appfinalstorage=FirebaseStorage.instanceFor(app:customApp);
مراحل بعدی
برای راه اندازی برنامه خود آماده شوید:
برای اطمینان از اینکه فقط برنامههای شما میتوانند به سطلهای ذخیرهسازی شما دسترسی داشته باشند ، بررسی برنامه را فعال کنید.
هشدارهای بودجه را برای پروژه خود در Google Cloud Console تنظیم کنید.
تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-07-25 بهوقت ساعت هماهنگ جهانی."],[],[],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\n1. If you haven't already, make sure you've completed the\n [getting started guide for Flutter apps](/docs/flutter/setup).\n This includes:\n\n - Creating a Firebase project.\n\n - Installing and initializing the Firebase SDKs for Flutter.\n\n2. Make sure your Firebase project is on the [pay-as-you-go Blaze pricing plan](/pricing). If\n you're new to Firebase and Google Cloud, check if you're eligible for a\n [$300 credit](/support/faq#pricing-free-trial).\n\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 lets you\ndefine 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 [Firebase 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\nAdd the Cloud Storage SDK to your app\n\n1. From the root of your Flutter project, run the following command to install\n the plugin:\n\n flutter pub add firebase_storage\n\n2. Once complete, rebuild your Flutter application:\n\n flutter run\n\n3. Import the plugin in your Dart code:\n\n import 'package:firebase_storage/firebase_storage.dart';\n\nSet up Cloud Storage\n\n1. Run `flutterfire configure` from your Flutter project directory. This\n updates the Firebase config file (`firebase_options.dart`) in your app's\n codebase so that it has the name of your default Cloud Storage bucket.\n\n | **Note:** Alternatively to updating your config file, you can explicitly specify the bucket name when you create an instance of `FirebaseStorage` (see next step). You can find the bucket name in the [Cloud Storage *Files* tab](https://console.firebase.google.com/project/_/storage/) of the Firebase console.\n2. Access your Cloud Storage bucket by creating an instance of\n `FirebaseStorage`:\n\n final storage = FirebaseStorage.instance;\n\n // Alternatively, explicitly specify the bucket name URL.\n // final storage = FirebaseStorage.instanceFor(bucket: \"gs://\u003cvar\u003eBUCKET_NAME\u003c/var\u003e\");\n\nYou're ready to start using Cloud Storage!\n\nNext step? Learn how to\n[create a Cloud Storage reference](/docs/storage/flutter/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](#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\n[use a custom Firebase App](#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 // Get a non-default Storage bucket\n final storage = FirebaseStorage.instanceFor(bucket: \"gs://my-custom-bucket\");\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 gsutil -m acl ch -r -u service-PROJECT_NUMBER@gcp-sa-firebasestorage.iam.gserviceaccount.com gs://YOUR-CLOUD-STORAGE-BUCKET\n\nYou can find your project number as described in the [introduction to\nFirebase 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 can\ncreate an instance of `FirebaseStorage` initialized with that app: \n\n // Use a non-default App\n final storage = FirebaseStorage.instanceFor(app: customApp);\n\nNext steps\n\n- Prepare to launch your app:\n - Enable [App Check](/docs/app-check) to help ensure that only your apps can access your storage buckets.\n - Set up [budget 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* 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* dashboard](//console.firebase.google.com/project/_/storage/usage) for more detailed usage information.\n - Review the [Firebase launch checklist](/support/guides/launch-checklist)."]]