Flutter Firebase 存储上传时间过长但仅在 IOS 上

Veo*_*xer 0 ios dart flutter firebase-storage

我正在为我的 Android 和 ios 应用程序开发上传功能,并且我正在使用 Firebase Storage。我正在上传大小仅超过 100kb 的小图像。在我的 Android 设备上一切正常,但由于某种原因我的 ios 无法按预期工作。这是有问题的代码:

      final snapshot = await _firebaseStorage
          .ref()
          .child("$profilePicsFolder/$fileName")
          .putFile(resImg);
      final String imgUrl = await snapshot.ref.getDownloadURL();
      await auth.updateUserProfilePicture(photoUrl: imgUrl);
Run Code Online (Sandbox Code Playgroud)

这里的问题是 putFile() 在 ios 上需要很长时间,但在 android 上只需要几秒钟。我注意到,即使执行仍在等待 putFile() 函数几分钟,当我直接检查 Firebase 存储时,我注意到文件几乎立即上传。

不确定我在这里做错了什么。

小智 5

在IOS应用程序中使用putData()代替putFile()将有助于解决此类问题。