微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用 firestore 读取存储空间中的图片?

如何解决如何使用 firestore 读取存储空间中的图片?

我正在尝试在我的存储设备上注册我的照片。所以基本上,我的用户需要在他的手机上(使用 imagepicker)捕捉他的照片,然后我想在我的 Firestore 存储上注册这张照片,然后在我的用户模型上注册这张照片。

用我的函数图片注册到y storage,但是路径好像不对

enter image description here

然后当我点击图片时她无法被阅读

enter image description here

我的代码也启用了拒绝:错误:[storage/file-not-found] 指定的本地文件在设备上不存在。 NativeFirebaseError: [storage/file-not-found] 指定的本地文件在设备上不存在。

这很奇怪,因为该路径已在我的存储中注册

也是我的功能

 <Icon
          name="camera-retro"
          size={30}
          color="#5DC1D3"
          onPress={async () =>
            launchImageLibrary(
              {
                mediaType: "photo",includeBase64: false,maxHeight: 200,maxWidth: 200,},async (response) => {
                let image = response.path;
                let reference = storage().ref("PicturesUsers/" + image);
                console.log(reference);

                const pathToFile =
                  `${utils.FilePath.PICTURES_DIRECTORY}/` + response.path;

                await reference.putFile(pathToFile);
                console.log(pathToFile);
              },async (response) => {
                firestore()
                  .collection("Users")
                  .doc(await AsyncStorage.getItem("userID"))
                  .update({
                    Picture: response,})
                  .then(async () => {
                    setResponse(response);

                    console.log(pathToFile);

                    firestore()
                      .collection("Users")
                      .doc(await AsyncStorage.getItem("userID"))
                      .get()
                      .then((documentSnapshot) => {
                        console.log("User exists: ",documentSnapshot.exists);

                        if (documentSnapshot.exists) {
                          console.log(
                            "User data: ",documentSnapshot.data().Picture.uri
                          );
                        }
                      });
                  });
              }
            )
          }
        />

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。