خطاهای مربوط به فضای ذخیره سازی ابری در اندروید را مدیریت کنید
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
گاهی اوقات همه چیز طبق برنامه پیش نمی رود و خطایی رخ می دهد.
در صورت شک، خطای برگشتی را بررسی کنید و ببینید پیام خطا چه می گوید. کد زیر یک پیاده سازی کنترل کننده خطای سفارشی را نشان می دهد که کد خطا و پیام خطای بازگردانده شده توسط Cloud Storage را بررسی می کند. چنین کنترل کننده های خطا را می توان به اشیاء مختلف مورد استفاده در Cloud Storage API اضافه کرد (به عنوان مثال، UploadTask
و FileDownloadTask
).
Kotlin
internal inner class MyFailureListener : OnFailureListener {
override fun onFailure(exception: Exception) {
val errorCode = (exception as StorageException).errorCode
val errorMessage = exception.message
// test the errorCode and errorMessage, and handle accordingly
}
}
Java
class MyFailureListener implements OnFailureListener {
@Override
public void onFailure(@NonNull Exception exception) {
int errorCode = ((StorageException) exception).getErrorCode();
String errorMessage = exception.getMessage();
// test the errorCode and errorMessage, and handle accordingly
}
}
اگر پیام خطا را بررسی کردهاید و Cloud Storage Security Rules دارید که به شما اجازه میدهد، اما همچنان در تلاش برای رفع خطا هستید، از صفحه پشتیبانی ما دیدن کنید و به ما اطلاع دهید که چگونه میتوانیم کمک کنیم.
مدیریت پیام های خطا
دلایل متعددی وجود دارد که ممکن است خطا رخ دهد، از جمله فایل موجود نیست، کاربر اجازه دسترسی به فایل مورد نظر را ندارد، یا کاربر بارگذاری فایل را لغو می کند.
برای تشخیص صحیح مشکل و رسیدگی به خطا، در اینجا لیست کاملی از تمام خطاهایی که مشتری ما مطرح می کند و نحوه وقوع آنها آورده شده است. کدهای خطا در این جدول در کلاس StorageException
به عنوان ثابت های عدد صحیح تعریف می شوند.
کد | دلیل |
---|
ERROR_UNKNOWN | یک خطای ناشناخته رخ داد. |
ERROR_OBJECT_NOT_FOUND | هیچ شیئی در مرجع مشخص شده وجود ندارد. |
ERROR_BUCKET_NOT_FOUND | هیچ سطلی برای Cloud Storage پیکربندی نشده است |
ERROR_PROJECT_NOT_FOUND | هیچ پروژه ای برای Cloud Storage پیکربندی نشده است |
ERROR_QUOTA_EXCEEDED | از سهمیه سطل Cloud Storage شما فراتر رفته است. اگر از طرح قیمتگذاری Spark استفاده میکنید، به طرح قیمتگذاری Blaze بهصورت رایگان ارتقا دهید. اگر قبلاً در طرح قیمت گذاری Blaze هستید، با پشتیبانی Firebase تماس بگیرید.
مهم : از 1 اکتبر 2025 ، برنامه قیمت گذاری Blaze برای استفاده از Cloud Storage ، حتی از سطل های پیش فرض الزامی است . |
ERROR_NOT_AUTHENTICATED | کاربر احراز هویت نشده است، لطفا احراز هویت کنید و دوباره امتحان کنید. |
ERROR_NOT_AUTHORIZED | کاربر مجاز به انجام عمل درخواستی نیست، قوانین خود را برای اطمینان از صحت آنها بررسی کنید. |
ERROR_RETRY_LIMIT_EXCEEDED | حداکثر محدودیت زمانی برای یک عملیات (آپلود، دانلود، حذف و غیره) از بین رفته است. دوباره امتحان کنید. |
ERROR_INVALID_CHECKSUM | فایل روی کلاینت با جمع کنترلی فایل دریافت شده توسط سرور مطابقت ندارد. دوباره آپلود کنید. |
ERROR_CANCELED | کاربر عملیات را لغو کرد. |
علاوه بر این، تلاش برای فراخوانی getReferenceFromUrl()
با URL نامعتبر منجر به پرتاب یک IllegalArgumentException
می شود. آرگومان روش فوق باید به شکل gs://bucket/object
یا https://firebasestorage.googleapis.com/v0/b/bucket/o/object?token=<TOKEN>
باشد.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-22 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-22 بهوقت ساعت هماهنگ جهانی."],[],[],null,["\u003cbr /\u003e\n\nSometimes things don't go as planned and an error occurs.\n\nWhen in doubt, check the error returned and see what the error message says.\nThe following code shows a custom error handler implementation that inspects\nthe error code and error message returned by Cloud Storage. Such error\nhandlers can be added to various objects used in the Cloud Storage API (for\nexample, `UploadTask` and `FileDownloadTask`). \n\nKotlin \n\n```kotlin\ninternal inner class MyFailureListener : OnFailureListener {\n override fun onFailure(exception: Exception) {\n val errorCode = (exception as StorageException).errorCode\n val errorMessage = exception.message\n // test the errorCode and errorMessage, and handle accordingly\n }\n}https://github.com/firebase/snippets-android/blob/391c1646eacf44d2aab3f76bcfa60dfc6c14acf1/storage/app/src/main/java/com/google/firebase/referencecode/storage/kotlin/StorageActivity.kt#L492-L498\n```\n\nJava \n\n```java\nclass MyFailureListener implements OnFailureListener {\n @Override\n public void onFailure(@NonNull Exception exception) {\n int errorCode = ((StorageException) exception).getErrorCode();\n String errorMessage = exception.getMessage();\n // test the errorCode and errorMessage, and handle accordingly\n }\n}https://github.com/firebase/snippets-android/blob/391c1646eacf44d2aab3f76bcfa60dfc6c14acf1/storage/app/src/main/java/com/google/firebase/referencecode/storage/StorageActivity.java#L618-L625\n```\n\nIf you've checked the error message and have Cloud Storage Security Rules that allow your\naction, but are still struggling to fix the error, visit our\n[Support page](/support) and let us know how we can help.\n\nHandle Error Messages\n\nThere are a number of reasons why errors may occur, including the file\nnot existing, the user not having permission to access the desired file, or the\nuser cancelling the file upload.\n\nTo properly diagnose the issue and handle the error, here is a full list of all\nthe errors our client will raise, and how they can occur. Error codes in this\ntable are defined in the `StorageException` class as integer constants.\n\n| Code | Reason |\n|------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `ERROR_UNKNOWN` | An unknown error occurred. |\n| `ERROR_OBJECT_NOT_FOUND` | No object exists at the specified reference. |\n| `ERROR_BUCKET_NOT_FOUND` | No bucket is configured for Cloud Storage |\n| `ERROR_PROJECT_NOT_FOUND` | No project is configured for Cloud Storage |\n| `ERROR_QUOTA_EXCEEDED` | Quota on your Cloud Storage bucket has been exceeded. If you're on the Spark pricing plan, consider upgrading to the [pay-as-you-go Blaze pricing plan](/pricing). If you're already on the Blaze pricing plan, reach out to Firebase Support. **Important** : Starting October 1, 2025, the [Blaze pricing plan will be *required* to use Cloud Storage](/docs/storage/faqs-storage-changes-announced-sept-2024), even default buckets. |\n| `ERROR_NOT_AUTHENTICATED` | User is unauthenticated, please authenticate and try again. |\n| `ERROR_NOT_AUTHORIZED` | User is not authorized to perform the requested action, check your rules to ensure they are correct. |\n| `ERROR_RETRY_LIMIT_EXCEEDED` | The maximum time limit on an operation (upload, download, delete, etc.) has been excceded. Try again. |\n| `ERROR_INVALID_CHECKSUM` | File on the client does not match the checksum of the file received by the server. Try uploading again. |\n| `ERROR_CANCELED` | User canceled the operation. |\n\nAdditionally, attempting to call `getReferenceFromUrl()` with an invalid URL\nwill result in an `IllegalArgumentException` from being thrown. The argument to\nthe above method must be of the form `gs://bucket/object` or\n`https://firebasestorage.googleapis.com/v0/b/bucket/o/object?token=\u003cTOKEN\u003e`"]]