为了让我快速使用firebase存储,我必须在每个图像和存储桶上添加以下权限:实体:用户,名称:AllUsers,Access:Reader。有没有办法避免这种繁琐且不可扩展的方法,因为它的所有用户都上传了媒体?
我的firebase存储安全性如下所示:
service firebase.storage {
match /b/myapp.appspot.com/o {
match /proUsers/{userId}/{allPaths=**} {
allow read, write: if request.auth.uid == userId || request.resource.size < 2 * 1024 * 1024 || request.resource.contentType.matches('image/png') || request.resource.contentType.matches('image/jpeg');
}
}
}
我快速收到的错误是:Anonymous users does not have storage.objects.list access to bucket
如果我尝试直接访问图片,我会收到错误:Anonymous users does not have storage.objects.get access to object
我在哪里允许匿名用户具有读取功能?我假设设置允许读取就是这样做的。
答案 0 :(得分:0)
要允许匿名用户从您的数据库中读取(但不能写入),您可以将规则更改为:
service firebase.storage {
match /b/myapp.appspot.com/o {
match /proUsers/{userId}/{allPaths=**} {
allow write: if request.auth.uid == userId || request.resource.size < 2 * 1024 * 1024 || request.resource.contentType.matches('image/png') || request.resource.contentType.matches('image/jpeg');
allow read;
}
}
}