【问题标题】:react native firebase storage upload aborts on app close在应用程序关闭时反应本机 firebase 存储上传中止
【发布时间】:2023-01-21 21:45:21
【问题描述】:

我有这个功能,可以将图像上传到 firebase 存储。通常它可以工作,但是当用户在调用 ref.put(blob) 时关闭应用程序时,函数中止并且图像不会上传。如果应用程序关闭,是否有某种方法可以在后台继续此功能?

export const uploadImage = (uri) => (
  new Promise((resolve, reject) => {

      const ref = storage
        .ref()
        .child(//path);

          fetch(uri)
            .then((response) => {
                return response.blob();
            })
            .then((blob) => {
                return ref.put(blob);
            })
            .then(() => {
                resolve();
            })
            .catch((err) => {
                reject(err);
            })
  })
);

【问题讨论】:

    标签: firebase react-native file-upload blob firebase-storage


    【解决方案1】:

    Firebase 中没有内置任何用于在后台继续上传的内容。由于您标记为react-native,您可以考虑使用react-native-background-task之类的东西在后台执行整个上传。

    【讨论】:

      猜你喜欢
      • 2022-01-23
      • 2020-02-22
      • 2022-09-30
      • 1970-01-01
      • 2021-10-21
      • 1970-01-01
      • 2017-03-08
      • 2018-12-08
      • 1970-01-01
      相关资源
      最近更新 更多