Description
I notice different errors/exceptions across the Platform when a Firebase Storage deny access, like the issue #8066 but using Firebase Storage.
The exceptions are different by the platform Android and iOS.
This occurs in two cases:
The first case happen when a User WITH AUTORIZATION (by Firebase Storage Rules) try to read a file that DOESN'T EXIST a PlatormException is throw.
Using Android emulator/physical device:
PlatformException(
code: "object-not-found",
message: "com.google.firebase.storage.StorageException: Object does not exist at location.",
details: {"message": "No object exists at the desired reference."},
);
Using iOS emulator/physical device:
PlatformException(
code: "firebase_storage",
message: "No object exists at the desired reference.",
details: {"message": "No object exists at the desired reference."},
);
The second case happen when a User WITHOUT AUTORIZATION (by Firebase Storage Rules) try to read a file that EXIST a PlatormException is throw.
Using Android emulator/physical device:
PlatformException(
code: "firebase_storage",
message: "com.google.firebase.storage.StorageException: User does not have permission to access this object.",
details: {
"code": "unauthorized",
"message": "User is not authorized to perform the desired action."
},
);
Using iOS emulator/physical device:
PlatformException(
code: "unauthorized",
message: "User is not authorized to perform the desired action.",
details: {"message": "User is not authorized to perform the desired action."},
);
I'm aways use the exception code to know the type of exception. Could be nice normalize these exceptions to record or analyze better using tools like analytics, etc.
Adicional information: I test a lot of cases to validade if the Firebase Rules are working in a real scenario using the emulators and devices, and these are the unique cases that throw PlatformException
instead FirebaseException
.
firebase_storage: ^10.2.7
flutter version: 2.10.
Regards.