[英]Unable to download files from FireBase
I am trying to download a pdf file using Firebase. 我正在尝试使用Firebase下载pdf文件。 Whenever I click the item which should initiate the download, the download fails.
每当我单击应启动下载的项目时,下载都会失败。 And I get this message in the log monitor:-
我在日志监视器中收到此消息:
StorageException has occurred. 发生StorageException。 User does not have permission to access this object.
用户无权访问此对象。 Code: -13021 HttpResult: 403
代码:-13021 Http结果:403
My read/write permission in the Firebase console looks like this:- 我在Firebase控制台中的读/写权限如下所示:-
service firebase.storage {
match /b/savephoto-a1cc3.appspot.com/o {
match /{allPaths=**} {
// Allow access by all users
allow read, write;
}
}
}
Also my java code for downloading the file looks like this 另外我下载文件的Java代码看起来像这样
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReference();
StorageReference islandRef = storageRef.child("CSD-101").child("Midsems").child("2016").child("CSD101_MidSem.pdf");
File rootPath = new File(Environment.getExternalStorageDirectory(), "Question Papers");
if(!rootPath.exists()) {
rootPath.mkdirs();
}
final File localFile = new File(rootPath,"CSD-101 Midsems.pdf");
islandRef.getFile(localFile).addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
@Override
public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
Toast.makeText(Year2.this, "File Downloaded", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(Year2.this, "Download Failed", Toast.LENGTH_SHORT).show();
}
});
What can I do? 我能做什么?
you should update your firebase console rules with this code 您应该使用此代码更新Firebase控制台规则
{ "rules": {
".read": true,
".write": true}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.