تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
في بعض الأحيان، لا تسير الأمور كما هو مخطّط لها ويحدث خطأ.
عند الشك، تحقَّق من الخطأ الذي تم إرجاعه واطّلِع على ما تقوله رسالة الخطأ.
يعرض الرمز التالي عملية تنفيذ معالج أخطاء مخصّص يفحص رمز الخطأ ورسالة الخطأ التي تعرضها Cloud Storage. يمكن إضافة معالجات الأخطاء هذه إلى عناصر مختلفة مستخدَمة في واجهة برمجة التطبيقات Cloud Storage (على سبيل المثال، UploadTask وFileDownloadTask).
Kotlin
internalinnerclassMyFailureListener:OnFailureListener{overridefunonFailure(exception:Exception){valerrorCode=(exceptionasStorageException).errorCodevalerrorMessage=exception.message// test the errorCode and errorMessage, and handle accordingly}}
classMyFailureListenerimplementsOnFailureListener{@OverridepublicvoidonFailure(@NonNullExceptionexception){interrorCode=((StorageException)exception).getErrorCode();StringerrorMessage=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.
لم تتم مصادقة المستخدم، يُرجى المصادقة والمحاولة مرة أخرى.
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>
تاريخ التعديل الأخير: 2025-09-05 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-05 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],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/cc307b137a106d66a52fa6e9bee6f4f55dab9f76/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/cc307b137a106d66a52fa6e9bee6f4f55dab9f76/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`"]]