Firebase 存储安全规则和颤振

时间:2021-05-23 18:33:01

标签: flutter firebase-storage

我希望能够在身份验证之前将照片上传到 firebase 存储,并且每次上传图片时:控制台中都会弹出此错误:no auth token,即使我的 firebase 规则是公开的:

这是我的代码和 Firebase 规则:

代码

TextButton(
                        child: Icon(Icons.camera,color: Colors.black,),
                        onPressed: () async {
                          pickedImage = await ImagePicker().getImage(
                              source: ImageSource.gallery,
                              maxWidth: 1920,
                              maxHeight: 1200,
                              imageQuality: 80);
                          Reference reference =
                              FirebaseStorage.instance.ref().child("image.jpg");
                          await reference.putFile(File(pickedImage.path));
                          imageUrl = await reference.getDownloadURL();
                          _organization.value = _organization.value
                              .copyWith(credentials: imageUrl);
                        })

FirebaseRules

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

怎么办?

0 个答案:

没有答案