Firebase Storage, What's the proper rules for user based uploading/deleting?

前端 未结 1 806
耶瑟儿~
耶瑟儿~ 2021-02-06 08:36

I want to create user based security for Firebase/Storage. Below allow write works well if I do only upload images. But It prevents deleting a photo. How can I create proper sec

1条回答
  •  北海茫月
    2021-02-06 08:58

    I would use this to check if you are creating/updating a file or removing it

    match /users/{uid}/{filename} {
        allow write: if isCurrentUser(uid);
        allow write: if resource == null ||
             ( isImage() &&
             lessThanNMegabytes(n) &&
             request.resource !=null &&
             filename.size() < 50 );
    }
    

    0 讨论(0)
提交回复
热议问题