【问题标题】:Firebase storage error "No object exists at the desired reference and no auth token for request"Firebase 存储错误“所需引用处不存在对象且请求没有身份验证令牌”
【发布时间】:2021-03-06 07:57:01
【问题描述】:

当我尝试在我的 Firebase 存储中获取我的文件的下载 URL 时,我一直收到此错误,我不知道问题出在哪里,我尝试了很多方法

    Exception has occurred.
FirebaseException ([firebase_storage/object-not-found] No object exists at the desired reference.)

W/StorageUtil(32618): no auth token for request
W/NetworkRequest(32618): no auth token for request
E/StorageException(32618): StorageException has occurred.
E/StorageException(32618): Object does not exist at location.
E/StorageException(32618):  Code: -13010 HttpResult: 404

这是我的存储规则

service firebase.storage {
    match /{allPaths=**} {
      allow read;
    }
  }

这是我的代码

 return   GridView.builder(
                
    shrinkWrap: true,
  itemCount: snapshot.data.documents.length,
  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
    crossAxisSpacing: 20, 
    mainAxisSpacing: 20,
    childAspectRatio: 1.7,
      crossAxisCount:2),
  itemBuilder: (BuildContext context, int index) {

    checkItems =  FirebaseFirestore.instance
        .collection('items');

checkItems = checkItems..where('id',isEqualTo: user_id.toString()); 

    DocumentSnapshot thesnapshot = snapshot.data.docs[index]; 


    
                                                              printUrl() async {
    Reference ref = 
        FirebaseStorage.instance.ref().child('antivirus.jpg');
       
       var togo = (await ref.getDownloadURL()).toString();
    setState(() {
      url =  togo;
    print('here is your url duuuuuuuuuuuuuuuuuuuuuudreeeeeeeeee'+url);
    });
    
}

printUrl()

.................................................. ..................................................... .....................................

【问题讨论】:

  • 您能否:1) 更新代码以记录thesnapshot.data()['image'].toString() 的值? 2) 在您的问题中包含更新后的代码及其输出?
  • 我更新了我的代码,thesnapshot.data()['image'] 的值是 'antvirus.jpg' ,我把这个文件保存在我的云存储数据库中
  • 它给了我在代码开头写的同样的错误
  • 这与your previous question btw 有何不同?
  • 代码中的哪一行给出了错误?

标签: android firebase flutter dart firebase-storage


【解决方案1】:

我遇到了同样的问题,我修复了从方法中删除扩展名的问题,试试这样:

 Reference ref = 
    FirebaseStorage.instance.ref().child('antivirus');

它对我有用。

【讨论】:

    猜你喜欢
    • 2020-06-26
    • 2020-08-18
    • 1970-01-01
    • 2013-10-12
    • 2021-10-25
    • 2020-12-16
    • 2021-09-23
    • 1970-01-01
    相关资源
    最近更新 更多