如何在 iOS (Ionic 2/3) 中下载文件?

Set*_*sak 5 file ios ionic-framework ionic3

我正在尝试下载文件并将该文件保存在 iOS 中。我正在使用ionic-native-file插件来实现这一点。该文件已下载,但我在设备中找不到该文件。

filewrite = (): void => {
    let transfer = this.fileTransfer.create();
    let path = "";
    let dir_name = 'Download';
    let file_name = "Sample.pdf";

    if (this.platform.is('ios')) {
      this.platform.ready().then(() => {
          path = this.file.documentsDirectory;

          this.file.writeFile(path,file_name,this.pdfSrc).then((entry) => {
            this.showAlert("download completed");
          }, (error) => {
            this.showAlert("Download Failed.");
          }).catch(err=>{
            this.showAlert("Download Failed catch.");
            this.showAlert(err.message);

          });
        }
      )
    }
  };
Run Code Online (Sandbox Code Playgroud)

下载完成提示显示,下载路径为:

file:///var/mobile/Containers/Data/Application/6DE22F30-5806-4393-830A-14C8A1F320BE/Library/Cloud/Sample.pdf

但是我在设备中找不到那个位置。然后,我谷歌并看到这里

cordova.file.documentsDirectory - 应用程序私有的文件,但对其他应用程序有意义(例如 Office 文件)。请注意,对于 OSX,这是用户的 ~/Documents 目录。(iOS、OSX)

所以,我实际上看不到该文件,因为它是应用程序私有的。然后我在同一个链接中看到:

在此处输入图片说明

所以,我在我的 config.xml 中尝试了两者的偏好,但没有发生任何事情。

有什么方法可以下载文件 iOS 或 Dropbox 或其他任何地方?

BRa*_*ass 2

我也很难找到正确的目录来使用这个 cordova 插件在不同平台上保存。我开始file.externalRootDirectory在 Android 和file.cacheDirectoryiOS 上使用。

正确的位置可能取决于您打算如何处理该文件。就我而言,我只需要短期存储它,以便我可以使用用户的本机 PDF 阅读器打开它。