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文件名来访问图像

相关问题