首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >关于firebase存储规则匹配

关于firebase存储规则匹配
EN

Stack Overflow用户
提问于 2017-03-01 00:16:39
回答 1查看 532关注 0票数 2

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

代码语言:javascript
运行
复制
match /images/{userId}/{allPaths=**}

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

代码语言:javascript
运行
复制
match /images/user/userId_user.jpg

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

然后..。如果你知道使用uid,就不要使用match {userId}<-就像这样。

亲切的问候。

EN

回答 1

Stack Overflow用户

发布于 2017-03-01 23:55:03

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

代码语言:javascript
运行
复制
match /users/{userId}/images/{imageId} {
  allow write: if userId == request.auth.uid;
}

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

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

代码语言:javascript
运行
复制
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');
}
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42513762

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档