Handle errors for Cloud Storage on Fluttter
This page is archived and might not reflect the latest version of the FlutterFire plugins. You can find the latest information on firebase.google.com:
Sometimes when you're building an app, things don't go as planned and an error occurs!
When in doubt, catch the exception thrown by the function and see what the error message has to say.
By default, a Cloud Storage 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. Since Firebase and your project's default App Engine app share this bucket, configuring public access may make newly uploaded App Engine files publicly accessible, as well. Be sure to restrict access to your Cloud Storage bucket again when you set up Authentication.
#Handle Error Messages
There are a number of reasons why errors may occur, including the file not existing, the user not having permission to access the desired file, or the user cancelling the file upload.
To properly diagnose the issue and handle the error, here is a full list of all the errors our client will raise, and how they occurred.
|An unknown error occurred.|
|No object exists at the desired reference.|
|No bucket is configured for Cloud Storage|
|No project is configured for Cloud Storage|
|Quota on your Cloud Storage bucket has been exceeded. If you're on the no-cost tier, upgrade to a paid plan. If you're on a paid plan, reach out to Firebase support.|
|User is unauthenticated, please authenticate and try again.|
|User is not authorized to perform the desired action, check your security rules to ensure they are correct.|
|The maximum time limit on an operation (upload, download, delete, etc.) has been excceded. Try uploading again.|
|File on the client does not match the checksum of the file received by the server. Try uploading again.|
|User canceled the operation.|
|Invalid event name provided. Must be one of [|
|Invalid URL provided to |
|The argument passed to |
|No bucket has been set in your config's |
|Commonly occurs when the local file has changed (deleted, saved again, etc.). Try uploading again after verifying that the file hasn't changed.|
|File on the client does not match the size of the file recieved by the server. Try uploading again.|