2017-02-20 60 views
0

为了让我快速使用Firebase存储,我必须在每个图像和存储分区上添加以下权限:实体:用户,名称:AllUsers,Access:Reader。有没有办法避免这种繁琐和不可扩展的方法,因为它的所有用户上传的媒体?Firebase存储分区和Fastly CDN集成

我的火力存储安全如下所示:

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

允许匿名用户从数据库读取(但不能写入),你可以改变你的规则是:

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; 
    } 
    } 
}