【问题标题】:(Flutter) Can't download images with Cloud Storage(Flutter) 无法使用 Cloud Storage 下载图片
【发布时间】:2020-06-20 04:34:57
【问题描述】:


我收到此错误:

E/StorageUtil(21342): error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.
W/NetworkRequest(21342): no auth token for request


当我从https://stackoverflow.com/a/50877590/9272698 执行此代码时(从带有 Firestore 存储的图像中获取下载 url):

 Future _getImageUrl() async {
    final ref = FirebaseStorage.instance.ref().child('lake');
    var url = await ref.getDownloadURL();
    return url;
  }


这不是由于我的 Firestore 规则,因为我让它像这样公开:

rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write;
    }
  }
}

此外,我认为这不是由于互联网连接造成的,因为我能够从 Firebase 云数据库加载字段。 你有解决方案吗?非常感谢

【问题讨论】:

    标签: firebase flutter google-cloud-storage firebase-storage


    【解决方案1】:

    我设法获得了我的网址图片。
    方法如下:

    1. 将 SAH-1 认证添加到您的项目 Firebase 并将新的 google-service 文件上传到您的项目
    2. 在调用 .getDownloadUrl() 之前让您的用户匿名登录(并在您的 firebase 项目中启用它)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-13
      • 1970-01-01
      • 1970-01-01
      • 2020-09-30
      • 1970-01-01
      • 2016-11-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多