Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Storage Allow Deleting Files

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.

like image 607
Vad Avatar asked Nov 10 '16 18:11

Vad


Video Answer


1 Answers

Found it:

request.resource == null

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

like image 102
Vad Avatar answered Sep 25 '22 19:09

Vad