Firebase document upload failing with Storage Exception, but rules and logging in works

Viewed 37

After some amazing help from this community getting my client's app working and finding where to make UI edits, I am at an impasse. This issue was occurring ever since my client removed the last contractor on the app, and it seems like you can no longer upload anything to the firebase server anymore through our app. Thanks to this community, I have my app building properly with visual changes I have made, and I can still login on both my virtual device and my actual apk on my phone. All of my clients who have the test app can still log in to their accounts. I have been getting more savvy with the world of mobile app development, and I tried exploring some solutions other users had, including specific rules for the Cloud Firestore, and checking that the firebase_options.dart file was properly configured with the app hash keys and identifiers found on the firebase project settings portal. My app also has permission to access my local storage too, which I saw some solutions mentioning. Forgive my error log dump, but this seems to be the chunk of errors getting thrown on each click of my upload button.


09-05 23:01:34.146 10121 19842 22377 E StorageException: StorageException has occurred.
09-05 23:01:34.146 10121 19842 22377 E StorageException: User does not have permission to access this object.
09-05 23:01:34.146 10121 19842 22377 E StorageException:  Code: -13021 HttpResult: 403
09-05 23:01:34.151 10121 19842 22377 E StorageException: The server has terminated the upload session
09-05 23:01:34.151 10121 19842 22377 E StorageException: java.io.IOException: The server has terminated the upload session
09-05 23:01:34.151 10121 19842 22377 E StorageException:    at com.google.firebase.storage.UploadTask.serverStateValid(UploadTask.java:339)
09-05 23:01:34.151 10121 19842 22377 E StorageException:    at com.google.firebase.storage.UploadTask.shouldContinue(UploadTask.java:308)
09-05 23:01:34.151 10121 19842 22377 E StorageException:    at com.google.firebase.storage.UploadTask.run(UploadTask.java:229)
09-05 23:01:34.151 10121 19842 22377 E StorageException:    at com.google.firebase.storage.StorageTask.lambda$getRunnable$7$com-google-firebase-storage-StorageTask(StorageTask.java:1072)
09-05 23:01:34.151 10121 19842 22377 E StorageException:    at com.google.firebase.storage.StorageTask$$ExternalSyntheticLambda3.run(Unknown Source:2)
09-05 23:01:34.151 10121 19842 22377 E StorageException:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
09-05 23:01:34.151 10121 19842 22377 E StorageException:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
09-05 23:01:34.151 10121 19842 22377 E StorageException:    at java.lang.Thread.run(Thread.java:923)
09-05 23:01:34.151 10121 19842 22377 E StorageException: Caused by: java.io.IOException: {  "error": {    "code": 403,    "message": "Permission denied."  }}
09-05 23:01:34.151 10121 19842 22377 E StorageException:    at com.google.firebase.storage.network.NetworkRequest.parseResponse(NetworkRequest.java:445)
09-05 23:01:34.151 10121 19842 22377 E StorageException:    at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(NetworkRequest.java:462)

I am going to continue investigating this error myself, and I'll report back on any findings.

I'm new to these mobile development sdks and settings, so I'm sure I'm missing something silly somewhere. I'm tagging Gradle and Flutter too, because I'm honestly not sure if its a firebase config setting contained in one of those build files.

Cheers.

1 Answers

It turns out I had found the correct solution, but was putting it in the wrong server rules. Firestore and Cloud Storage are different products, with different rules.

So thank you Dharmaraj for pointing that out to me. My Firebase portal had the storage menu buried in the All Products sections. Rookie mistake on my part, but I'm so happy this is working now!

Related