1

我想從FirebaseStorage下載一些圖像。獲取'用戶沒有權限訪問此對象。代碼:-13021 HttpResult:403'錯誤。請參閱詳細信息

雖然我通過谷歌認證的用戶,我仍然得到這個 錯誤:

E/StorageException: StorageException has occurred. User does not have permission to access this object. Code: -13021 HttpResult: 403

試圖下載的圖像時。

這裏的規則:

service firebase.storage { 
    match /b/appname-e3a12.appspot.com/o { 
    match /{allPaths=**} { 
     allow read, write; 
    } 
    } 
} 

請讓我知道什麼是錯在這裏。

有沒有人得到這個答案?

對不起,如果問題似乎格式不正確。我還是個初學者!

回答

3

嘗試

service firebase.storage { 
    match /b/appname-e3a12.appspot.com/o { 
    match /{allPaths=**} { 
    allow read, write: if true; 
    } 
} 
} 
+0

我應該在哪裏插入此:'appname-e3a12.appspot.com '? –

+0

不!即使這個規則也給出了同樣的錯誤:'E/StorageException:發生了StorageException。用戶沒有權限訪問此對象。代碼:-13021 HttpResult:403' –

+0

我也是初學者。我不知道更多。爲什麼不認證?如果你不想嘗試 [Firebase匿名登錄](https://firebase.google.com/docs/auth/android/anonymous-auth) –

1

你的規則看起來不錯,但如果你不知道,嘗試把allow read, write: if true;到你的規則根源。

我有同樣的問題,我不知道您嘗試從哪個平臺訪問Firebase存儲,但請檢查代碼中的引用樣式。存儲與數據庫不同。 例如在Android中,你應該訪問文件就像這樣:

StorageReference storageRef = FirebaseStorage.getInstance().reference().child("folderName/file.jpg"); 

不喜歡這樣的:

StorageReference storageRef = FirebaseStorage.getInstance().reference().child("folderName").child("file.jpg"); 

你也應該閱讀大衛東這個博客帖子:5 tips for Firebase Storage

1

有同樣的問題,這是不夠的,允許讀/寫,也應該啓用Firebase控制檯/身份驗證/ SIGN0IN方法選項卡下的匿名帳戶,然後它的工作。

0

您是否嘗試過使用Firebase的默認規則?

service firebase.storage { 
    match /b/<your-firebase-storage-bucket>/o { 
     match /{allPaths=**} { 
      allow read, write: if request.auth != null; 
     } 
    } 
} 

希望這有助於!

0

我也面臨同樣的問題,然後我發現,我們需要提及,即使在firebaseReference文件名來訪問圖像

相關問題