Menangani error untuk Cloud Storage di Web
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Terkadang, ketika Anda membuat aplikasi, ada hal-hal yang tidak berjalan sesuai rencana
dan terjadi error.
Jika merasa ragu, periksa handler error (atau fungsi catch()
untuk Promise), dan lihat isi pesan error tersebut.
Jika Anda telah memeriksa pesan error dan memiliki Cloud Storage Security Rules yang mengizinkan tindakan Anda, tetapi masih kesulitan dalam memperbaiki error tersebut, buka halaman Dukungan dan beri tahu kami bantuan apa yang diperlukan.
Menangani Pesan Error
Ada beberapa alasan mengapa terjadi error, termasuk tidak adanya file, pengguna tidak memiliki izin untuk mengakses file yang diinginkan, atau pengguna membatalkan upload file.
Untuk mendiagnosis masalah dan menangani error dengan benar, berikut ini daftar lengkap semua error yang dialami klien kami, dan bagaimana error tersebut terjadi.
Kode |
Alasan |
storage/unknown |
Terjadi error tak dikenal. |
storage/object-not-found |
Tidak ada objek pada referensi yang ditentukan. |
storage/bucket-not-found |
Tidak ada bucket yang dikonfigurasi untuk Cloud Storage |
storage/project-not-found |
Tidak ada project yang dikonfigurasi untuk Cloud Storage |
storage/quota-exceeded |
Kuota di bucket Cloud Storage telah terlampaui. Jika Anda menggunakan paket harga Spark, pertimbangkan untuk mengupgrade ke paket harga Blaze bayar sesuai penggunaan. Jika Anda sudah menggunakan paket harga Blaze, hubungi Dukungan Firebase.
Penting: Mulai 1 Oktober 2025, paket harga Blaze akan diperlukan untuk menggunakan Cloud Storage, bahkan bucket default. |
storage/unauthenticated |
Pengguna tidak terautentikasi. Autentikasi pengguna, lalu coba lagi. |
storage/unauthorized |
Pengguna tidak memiliki izin untuk melakukan tindakan yang diminta. Periksa aturan keamanan Anda untuk memastikan bahwa aturan tersebut sudah benar. |
storage/retry-limit-exceeded |
Batas waktu maksimum pada operasi (upload, download, hapus, dll.)
telah terlampaui. Coba upload lagi. |
storage/invalid-checksum |
File pada klien tidak cocok dengan checksum file yang diterima oleh server. Coba upload lagi. |
storage/canceled |
Pengguna membatalkan operasi. |
storage/invalid-event-name |
Nama peristiwa yang diberikan tidak valid. Harus berupa salah satu dari
[`running` , `progress` , `pause` ] |
storage/invalid-url |
URL yang tidak valid diberikan untuk refFromURL() . Harus berupa:
gs://bucket/object atau https://firebasestorage.googleapis.com/v0/b/bucket/o/object?token=<TOKEN> |
storage/invalid-argument |
Argumen yang diteruskan ke put() harus berupa array `File`, `Blob`, atau
`UInt8`. Argumen yang diteruskan ke putString() harus berupa string mentah, `Base64`, atau, `Base64URL`. |
storage/no-default-bucket |
Tidak ada bucket yang telah ditetapkan di properti storageBucket konfigurasi Firebase Anda. |
storage/cannot-slice-blob |
Biasanya terjadi ketika file lokal berubah (dihapus, disimpan lagi, dll.). Coba upload lagi setelah memverifikasi bahwa file tersebut tidak berubah. |
storage/server-file-wrong-size |
File pada klien tidak cocok dengan ukuran file yang diterima oleh server. Coba upload lagi. |
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-08-31 UTC.
[null,null,["Terakhir diperbarui pada 2025-08-31 UTC."],[],[],null,["\u003cbr /\u003e\n\nSometimes when you're building an app, things don't go as planned and an\nerror occurs!\n\nWhen in doubt, check the error handler (or `catch()` function for Promises),\nand see what the error message has to say.\n| **Note:** By default, a Cloud Storage for Firebase bucket requires Firebase Authentication to perform any action on the bucket's data or files. You can change your Firebase Security Rules for Cloud Storage to [allow unauthenticated access for specific situations](/docs/storage/security/rules-conditions#public). However, for most situations, we strongly recommend [restricting access and setting up robust security rules](/docs/storage/security/get-started) (especially for production apps). Note that if you use Google App Engine and have a default Cloud Storage bucket with a name format of `*.appspot.com`, you may need to consider [how your security rules impact access to App Engine files](/docs/storage/gcp-integration#security-rules-and-app-engine-files).\n\nIf you've checked the error message and have Cloud Storage Security Rules that allow your\naction, but are still struggling to solve 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\nall the errors our client will raise, and how they occurred.\n\n| Code | Reason |\n|----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `storage/unknown` | An unknown error occurred. |\n| `storage/object-not-found` | No object exists at the specified reference. |\n| `storage/bucket-not-found` | No bucket is configured for Cloud Storage |\n| `storage/project-not-found` | No project is configured for Cloud Storage |\n| `storage/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| `storage/unauthenticated` | User is unauthenticated, please authenticate and try again. |\n| `storage/unauthorized` | User is not authorized to perform the requested action, check your security rules to ensure they are correct. |\n| `storage/retry-limit-exceeded` | The maximum time limit on an operation (upload, download, delete, etc.) has been exceeded. Try uploading again. |\n| `storage/invalid-checksum` | File on the client does not match the checksum of the file received by the server. Try uploading again. |\n| `storage/canceled` | User canceled the operation. |\n| `storage/invalid-event-name` | Invalid event name provided. Must be one of \\[```running```, ```progress```, ```pause```\\] |\n| `storage/invalid-url` | Invalid URL provided to `refFromURL()`. Must be of the form: gs://bucket/object or https://firebasestorage.googleapis.com/v0/b/bucket/o/object?token=\\<TOKEN\\\u003e |\n| `storage/invalid-argument` | The argument passed to `put()` must be \\`File\\`, \\`Blob\\`, or \\`UInt8\\` Array. The argument passed to `putString()` must be a raw, \\`Base64\\`, or \\`Base64URL\\` string. |\n| `storage/no-default-bucket` | No bucket has been set in your Firebase config's `storageBucket` property. |\n| `storage/cannot-slice-blob` | Commonly occurs when the local file has changed (deleted, saved again, etc.). Try uploading again after verifying that the file hasn't changed. |\n| `storage/server-file-wrong-size` | File on the client does not match the size of the file received by the server. Try uploading again. |"]]