I have been trying to upload images to the new firebase storage service . It is throwing StorageException
E/StorageException: StorageException has occ
In your firebase console, go to the storage tab on the left. Click on the rules tab and set your rule to public. Use the following code to set it to public.
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write;
}
}
}
This is good for testing purpose, however, you should secure your DB connection using authenticate users.
In the google firebase this type of StorageException
are commonly caused because of wrong
StorageReference
reference .
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl("gs://<your-bucket-name>");
// Create a reference to "file"
StorageReference mountainsRef = storageRef.child("file.jpg");
Make sure the reference to the file is made correctly.
Details about creating Storage reference can be found in here
Details about the Storage Exception codes can be found in here for further refrences