【问题标题】:How to move file from app Document folder to Iphone's document folder using react-native-fetch-blob如何使用 react-native-fetch-blob 将文件从 app Document 文件夹移动到 Iphone 的文件夹
【发布时间】:2017-02-13 18:34:33
【问题描述】:

我正在使用 react-native-fetch-blob 下载 excel 文件,这些文件存储在我无法在 iphone 中打开的 app/documents 文件夹中,而且我不知道 iphone 文档文件夹的绝对路径将文件保存在那里。

这是我的代码:

downloadFile(){
    const dirs = RNFetchBlob.fs.dirs;
    let context = this,
        userBarRelationId = context.state.userBarId;
    RNFetchBlob
  .config({
    fileCache : true,
    path : dirs.DocumentDir + '/excel.xlsx'
  })
  .fetch('GET', 'http://localhost:5000/getExcel/'+userBarRelationId, {
  })
  .then((res) => {
    console.log('The file saved to ', res.path(), res.data)
  })
  }

【问题讨论】:

    标签: javascript ios iphone reactjs react-native


    【解决方案1】:

    等等,您要求将数据保存在您的沙盒应用程序有权访问的文件夹之外的文档文件夹中?

    这在 iOS 设计中是不可能的。另见here。甚至一分钟的谷歌搜索都没有告诉你这一点,更不用说它基本上是一个核心原则。

    如果我不理解你,我很抱歉,但我不知道你想知道什么。如果您询问如何将文件保存到用户的 iCloud Drive(其中也有一个 Documents 文件夹),您将不得不投入更多的工作。我自己从来没有做过,但一个很好的起点是this

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-10
      • 1970-01-01
      • 2021-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-20
      相关资源
      最近更新 更多