Reputation: 101
I have added a portion of my app which the user can upload a profile image but for some reason i get a firebase error saying i/user doesnt have permission even though the rules show it is accessible for all to read and write given the auth is not null. I want users that have logged in to be allowed to read/write.
My firebase storage rules
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if request.auth != null;
}
}
}
stacktrace:
03-21 11:46:26.851 13033-13033/com.dogboy60.photoblog E/StorageException: The server has terminated the upload session
java.io.IOException: The server has terminated the upload session
at com.google.firebase.storage.UploadTask.zzLb(Unknown Source:21)
at com.google.firebase.storage.UploadTask.zzLa(Unknown Source:58)
at com.google.firebase.storage.UploadTask.run(Unknown Source:259)
at com.google.firebase.storage.zzr.run(Unknown Source:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
03-21 11:46:26.865 13033-13033/com.dogboy60.photoblog E/Error here:: com.google.firebase.storage.StorageException: User does not have permission to access this object.
Upvotes: 2
Views: 7672
Reputation: 793
Instead of allowing anybody to be able to do anything with your data use this:
allow read, write: if request.auth != null;
Upvotes: 1
Reputation:
You can change the Firebase rule like below code .. remove only if condition.
service firebase.storage {
match /b/sacred-age-861.appspot.com/o {
match /{allPaths=**} {
allow read, write;
}
}
}
Upvotes: 1