0
votes

I am building an android app and I need to add security rules to Firebase Storage. My App has groups and the file path on storage is /{groupId}/Images/{allPaths=**} and I want to give read and write permission to the members of that group. How can I pass a list of uids to customMetadata() and add corresponding rule for that. Another question is about the rules for write permission: In Firebase, an image is uploaded first and then its metadata can be updated. So if a write rule contains some check on metadata, won't it fail at the time of upload?

PS: I have tried various solutions but all of them failed. One solution was to add uids as keys in customMetadata() and keep value as empty string. But even this didn't work. Any help is appreciated. Thanks.

Update: I added uids as keys in customMetadata() and it worked in read mode security rule but I am still facing error in write mode because while uploading file request.resource.metadata is null.

1
Update the current security rules here.fatalcoder524
I followed stackoverflow.com/questions/39549334/… for read mode security rules.Komal Chugh

1 Answers

0
votes

I solved this issue. I was updating metadata after file upload whereas I had to add metadata during file upload. Refer to Add File Metadata section in the docs: https://firebase.google.com/docs/storage/android/upload-files