从 Firebase 存储获取图像时出错

问题描述 投票:0回答:1

出现此错误

error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.

我已将 Firebase 存储规则更改为

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

这是我的代码

getImageFirebase(String locations, String imageName) {
  String check = "";
  check =
      storageRef.child(locations).child(imageName).getDownloadURL().toString();

  return check;
}

为什么我更改规则后总是需要令牌?

flutter firebase-storage
1个回答
0
投票

你必须像这样更新你的规则:

 rules_version = '2';
 service firebase.storage {
 match /b/{bucket}/o {
 match /{allPaths=**} {
  allow read, write: if request.auth != null;
}

} }

© www.soinside.com 2019 - 2024. All rights reserved.