Firebase Storage Allow Deleting Files

人走茶凉 提交于 2020-01-02 04:55:12

问题


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:


Found it:

request.resource == null

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



来源:https://stackoverflow.com/questions/40534295/firebase-storage-allow-deleting-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!