【问题标题】:Fire Storage Exception ([firebase_storage/unauthorized] User is not authorized to perform the desired action.) (my rule is allow read/write)Fire Storage Exception([firebase_storage/unauthorized] 用户无权执行所需的操作。)(我的规则是允许读/写)
【发布时间】:2021-03-10 21:18:20
【问题描述】:

我正在尝试从 firebase firestore 获取图像,同时尝试获取图像下载 url 时出现此异常:

W/StorageUtil(10206):请求没有身份验证令牌

(与此错误类似的问题不能解决问题)

虽然我的安全规则允许读写,但我仍然收到此错误。

任何想法这是什么问题?

获取图片url的代码:

  static Future<dynamic> loadImage(BuildContext context, String image) async {
    return await FirebaseStorage.instance.ref().child(image).getDownloadURL();
  }

调用这个 loadImage 函数:

  Future<Widget> getImage(BuildContext context, String imgName) async {
   Image image;
    await FireStorageService.loadImage(context, imgName).then((value) {
    print(value);
    image = Image.network(value.toString(), fit: BoxFit.scaleDown);
    return image;
   });
  }

调用这个 getImage 函数:

child: FutureBuilder(
future: getImage(context, "/images/test1.jpg"),
...
)

我的 Firebase 存储规则:

rules_version = '2';
service firebase.storage {
match /images/{imageId} {
  allow read,write;
}
}

存储规则ss:

我的 firebase 商店目前:

【问题讨论】:

  • 您能否也提供您的“规则”部分的屏幕截图?
  • 我刚刚添加了@Akif

标签: firebase flutter dart flutter-android


【解决方案1】:
  • 导航到 Firebase 控制台

  • 在开发开放存储下的侧边栏中

  • 打开规则选项卡将控制台上的规则替换为以下规则:

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

然后发布 完成

【讨论】:

    猜你喜欢
    • 2021-07-15
    • 2020-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-11
    • 2011-03-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多