@dsgriffin wrote:
I have files (located inside the
www/
folder) that I want the user to be able to download locally to their iOS/Android device.I'm attempting to use the download method of the cordova-plugin-file-transfer, but as Ionic 2 is so new (and I'm v. new to Ionic/Angular in general) I'm unable to discover the correct paths etc.
I've managed to get it like so:
downloadFile(file) { this.platform.ready().then(() => { const fileTransfer = new FileTransfer(); const pdfLocation = `${cordova.file.applicationDirectory}www/${file}`; const targetPath = cordova.file.documentsDirectory + "file.txt"; fileTransfer.download(file, targetPath, (result) => { console.log("success"); }, (error) => { console.log("error"); } ); }); }
But I receive the "error" message each time - am I using the correct folders/approach for this?
Posts: 1
Participants: 1