【发布时间】:2021-09-12 19:27:59
【问题描述】:
E/StorageException: StorageException has occurred.
Object does not exist at location.
Code: -13010 HttpResult: 404
2021-09-13 00:52:49.705 20328-20869/com.dishanamdev.advibe E/StorageException: { "error": { "code": 404, "message": "Not Found. Could not get object", "status": "GET_OBJECT" }}
java.io.IOException: { "error": { "code": 404, "message": "Not Found. Could not get object", "status": "GET_OBJECT" }}
我在 Firebase 存储中的安全规则是
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if request.auth != null;
}
}
}
我的 java 代码。在这里,我无法理解写什么代替b 以及写什么代替firebase storage rules 写的bucket。
你能告诉我,与我的java代码相比,在上述两个地方写什么?
我尝试用user 代替b 和currentID 代替bucket,但没有成功。
这样:
rules_version = '2';
service firebase.storage {
match /user/{currentID}/o {
match /{allPaths=**} {
allow read, write: if request.auth != null;
}
}
}
public void onStart() {
super.onStart();
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
String currentId = user.getUid();
DocumentReference reference;
FirebaseFirestore firestore = FirebaseFirestore.getInstance();
reference = firestore.collection("user").document(currentId);
reference.get()
.addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if(task.getResult().exists()){
String nameResult = task.getResult().getString("name");
String bioResult = task.getResult().getString("bio");
nameET.setText(nameResult);
bioET.setText(bioResult);
}else{
Intent intent = new Intent(getActivity(),CreateProfile.class);
startActivity(intent);
}
}
});}
请帮帮我。
【问题讨论】:
-
这不是您的安全规则的问题。您尝试检索的文件不存在。请验证路径是否指向您存储桶中的有效对象
-
您能否提供任何文档链接,我可以从中学习如何编写正确的路径?
-
错误明确指出:code": 404, "message": "Not Found.无法获取对象。可能你的路径是错误的,正如弗兰克上面提到的那样。
-
请显示您的代码引发错误以及您如何尝试从存储中获取对象
-
我现在做了,先生。请检查一次,请帮助。
标签: android firebase firebase-storage