2

我是firebase存儲新手。任何人都可以告訴我如何使存儲文件公開閱讀和寫作?下面給出了由firebase提供的默認代碼。我應該做什麼改變?製作firebase存儲公開在android上閱讀和寫作

service firebase.storage { 
    match /b/image-view-b1cf5.appspot.com/o { 
    match /{allPaths=**} { 
     allow read, write: if request.auth != null; 
    } 
    } 
} 

回答

9

documentation解釋說,如果沒有提供規則表達式,規則計算結果爲true:

service firebase.storage { 
    match /b/image-view-b1cf5.appspot.com/o { 
    match /{allPaths=**} { 
     // Allow access by all users 
     allow read, write; 
    } 
    } 
} 
+0

這並不提醒我們,我們的存儲是公開的,因爲它在火力數據庫一樣。你確定這是公開的唯一途徑嗎? – ashay

+0

@ashay:如果您需要提醒,請在規則中添加評論。 –

14

FYI:如果你只想公共讀。

service firebase.storage { 
    match /b/image-view-b1cf5.appspot.com/o { 
    match /{allPaths=**} { 
     allow read; 
     allow write: if request.auth != null; 
    } 
    } 
} 
+0

好的;找不到如何設置d/t規則來讀取和寫入他們的文檔。 – dsharew

0
service firebase.storage { 
match /b/{bucket}/o { 
match /{allPaths=**} { 
    allow read, write; 
        } 
       } 
     } 
+3

這個答案是什麼(除了不好的縮進),以前的答案沒有? –