首页 > 解决方案 > 未处理的异常:[firebase_storage/object-not-found] 所需参考处不存在对象

问题描述

每当我尝试从 Firebase 存储中删除图像文件时,我都会收到此错误:

未处理的异常:[firebase_storage/object-not-found] 所需参考处不存在对象

我最近更新了所有的 firebase 包,从那以后我无法从 firebase 存储中删除图像

FirebaseStorage 中的文件夹 [![在此处输入图像描述][2]][2]

删除文件的代码。

deleteApartments(
   PersonalApartment personalApartment, Function apartmentDeleted) async {
      if (personalApartment.imageUrl != null) {
            for (int i = 0; i < personalApartment.imageUrl.length; i++) {
     Reference storageReference = FirebaseStorage.instance
        .ref()
        .child('/apartment_images')
        .child(personalApartment.imageUrl[i]);

         await storageReferences.delete();
        }
    } else {
      FirebaseFirestore.instance
       .collection('apartments')
         .doc(personalApartment.id)
           .delete();
      apartmentDeleted(personalApartment);
   }

        FirebaseFirestore.instance
        .collection('apartments')
        .doc(personalApartment.id)
        .delete();
        apartmentDeleted(personalApartment);
        print('images deleted');
 }

调试控制台

     2I/System.out(11910): (HTTPLog)-Static: isSBSettingEnabled false
     E/StorageException(11910): StorageException has occurred.
     E/StorageException(11910): Object does not exist at location.
     E/StorageException(11910):  Code: -13010 HttpResult: 404
     E/StorageException(11910): {  "error": {    "code": 404,    "message": 
    "Not Found.  Could not delete object",    "status": "DELETE_OBJECT"  }}
     E/StorageException(11910): java.io.IOException: {  "error": {    "code": 
    404,    "message": "Not Found.  Could not delete object",    "status": 
    "DELETE_OBJECT"  }}
     E/flutter (11910): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] 
     Unhandled Exception: [firebase_storage/object-not-found] No object 
     exists at the desired reference.

Firebase 存储中文件夹的图像 在此处输入图像描述

标签: firebaseflutterdartfirebase-storage

解决方案


推荐阅读