Firebase Storage Deletes Files

I have the following rules for uploading images in user messages, however current rules do not allow deleting a file.

How to change the rules so that the user can delete their photos?

What property in the variable requestindicates that the request DELETE?

  match /{uid}/posts/{pid}/{imageName} {
    allow read;
    allow write: if (uid == request.auth.uid)
        && ((
            ((imageName == "pic.jpg") || (imageName == "pic.png") || (imageName == "pic.gif"))
            && (request.resource.size < 5 * 1024 * 1024)
            && (request.resource.contentType.matches('image/.*')) 
      ));
  }

Is there something like this ?:

request.method == "DELETE"

I can not find anything in the documentation.

+4
source share
1 answer

Found:

request.resource == null

Hey Firebase developers, this should be in the docs!

+8
source

Source: https://habr.com/ru/post/1660429/


All Articles