5
votes

I have the following rules for user post image uploads, however current rules don't allow file deletion.

How can I modify the rules to allow user to delete his pictures?

What property on request variable indicates that a request is 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't find anything in the documentation.

1

1 Answers

11
votes

Found it:

request.resource == null

Hey, Firebase devs, this should be in the docs!