Reputation: 53
I want to grant a user something like that.
match /images/{userId}/{allPaths=**}
But my firebaseStorage path is like that.
match /images/user/userId_user.jpg
So I don't know how to match this paths.
And.. If you know use uid don't use match {userId}<- like that.
kind regard.
Upvotes: 2
Views: 576
Reputation: 15953
I recommend storing your files in a different format to make this easier:
match /users/{userId}/images/{imageId} {
allow write: if userId == request.auth.uid;
}
which can match /users/userId/images/user.jpeg
But if you're already in this format, you're lucky we provide string and regular expression matching:
match /images/user/{userImageName} {
// If you know it'll be just a straight string match, go for it
allow read if: userImageName == request.auth.uid + '_user.jpeg';
// Otherwise match using a regular expression
allow write if: userImageName.matches(request.auth.uid + '_user.jpeg');
}
Upvotes: 4