【问题标题】:About firebase storage rule match关于 Firebase 存储规则匹配
【发布时间】:2017-02-28 16:16:38
【问题描述】:

我想授予用户类似的权限。

match /images/{userId}/{allPaths=**}

但是我的firebaseStorage路径是这样的。

match /images/user/userId_user.jpg

所以我不知道如何匹配这些路径。

而且.. 如果您知道使用 uid,请不要使用 match {userId}

亲切的问候。

【问题讨论】:

    标签: firebase firebase-security firebase-storage


    【解决方案1】:

    我建议您以不同的格式存储您的文件,以使这更容易:

    match /users/{userId}/images/{imageId} {
      allow write: if userId == request.auth.uid;
    }
    

    可以匹配/users/userId/images/user.jpeg

    但如果您已经采用这种格式,那么您很幸运我们提供了字符串和正则表达式匹配:

    match /images/user/{userImageName} {
      // If you know it'll be just a straight string match, go for it
      allow read if: userImageName == request.auth.uid + '_user.jpeg';
      // Otherwise match using a regular expression
      allow write if: userImageName.matches(request.auth.uid + '_user.jpeg');
    }
    

    【讨论】:

      猜你喜欢
      • 2018-08-03
      • 2020-08-15
      • 2017-08-11
      • 2016-12-19
      • 2019-06-15
      • 2020-10-17
      • 2020-11-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多