2017-02-20 83 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; 
    } 
    } 
}