apache / cordova-plugin-file-transfer

Apache Cordova File Transfer Plugin
https://cordova.apache.org/
Apache License 2.0
598 stars 885 forks source link

Downloaded pdf files disappear after app rebuild on iOS platform #227

Open benazir0 opened 5 years ago

benazir0 commented 5 years ago

Bug Report

Problem

Downloaded PDF files disappear after an app rebuild on iOS platform

What is expected to happen?

Downloaded files stay on the persistent storage permanently on iOS platforms

What does actually happen?

Downloaded files are not found after an app rebuild on iOS platform.

Information

I have downloaded PDF files from a website and then store the locations of the filenames on the local storage. Then I use FileOpener plugin to open PDF files. Whenever I rebuild the app, the file-opener cannot find any of the files on iOS platform -on Android, it is fine. I'm experiencing this issue for nearly 6 months or so. It used to work before perfectly. Please see the code snippet I use to download a pdf file.

Command or Code

private downloadPDF(pdf: IPdf, callback: (data) => void) {

const fileTransfer: FileTransferObject = this.transfer.create();

fileTransfer.download(pdf.Location, this.file.dataDirectory + pdf.Name).then((entry) => {

  if (this.platform.is('android')) {
    this.filePath.resolveNativePath(entry.toURL())
      .then(filePath => {
        callback(filePath);
      })
      .catch(err => console.log(JSON.stringify(err)));
  }
  else {
    callback(entry.toURL());
  }

}, (error) => {
  // handle error
});

}

Environment, Platform, Device

I'm using Ionic Framework version 3. Platforms: Android and iOS

Version information

Ionic:

ionic (Ionic CLI) : 4.1.1 Ionic Framework : ionic-angular 3.6.0 @ionic/app-scripts : 3.1.8

Cordova:

cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1) Cordova Platforms : android 6.4.0 Cordova Plugins : no whitelisted plugins (18 plugins total)

System:

Android SDK Tools : 26.1.1 (C:\Users[USERNAME]\AppData\Local\Android\sdk) NodeJS : v6.11.3 (C:\Program Files\nodejs\node.exe) npm : 6.5.0 OS : Windows 10

Checklist