【问题标题】:I am getting this exception: Object does not exist at location我收到此异常:对​​象不存在于该位置
【发布时间】: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 代替bcurrentID 代替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


【解决方案1】:

现在,我解决了这个问题。当我们没有在firebase中上传包含所有数据(包括照片,文本等)的对象时会出现此错误。因此,如果其他人在您拥有的java文件类中遇到同样的问题then must check your code again创建了 firebase 存储参考、数据库参考、文档参考

【讨论】:

    猜你喜欢
    • 2020-08-02
    • 1970-01-01
    • 2014-05-23
    • 2017-10-03
    • 2013-11-08
    • 1970-01-01
    • 2010-10-15
    • 1970-01-01
    • 2020-02-12
    相关资源
    最近更新 更多