I want to create custom security for Firebase / Storage. The below allow recording works well if I upload only images. But this prevents the deletion of the photo. How can I create the right security rule for this case?
service firebase.storage { match /b/<bucket>/o { match /{allPaths=**} { allow read: if request.auth != null; } match /users/{uid}/{filename} { allow write: if isCurrentUser(uid); allow write: if isImage() && isCurrentUser(uid) && lessThanNMegabytes(n) && request.resource !=null && filename.size() < 50; } } } function isCurrentUser(uid) { return request.auth.uid == uid; } function lessThanNMegabytes(n) { return request.resource.size < n * 1024 * 1024; } function isImage() { return request.resource.contentType.matches("image/.*"); }
source share