So I'm trying to set rules into storage, but I need to access to firestore to set it right.
Here is my example:
Into my firestore database I have a users
collection which have a collection named items
. The path look like this: /users/items/{itemId}
I want that a user can read and write a file into storage with this path: /items/{id}/file.png
only if the {id}
of the item already exist into the items
collection of firestore database.
Is there a way to set correctly rules into storage using firestore ?
I tried this:
service firebase.storage {
match /b/{bucket}/o {
match /items/{item}/{allPaths=**} {
allow read, write: if exists(/databases/{database}/documents/users/$(request.auth.uid)/items/$(item));
}
}
}
But this doesn't work :/
Thanks for your help!