Quantcast
Channel: Saving file to Downloads directory using Ionic 3 - Stack Overflow
Viewing all articles
Browse latest Browse all 7

Saving file to Downloads directory using Ionic 3

$
0
0

i know this link: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/#where-to-store-files

but i would like to save the file in Downloads directory. Is this possible to save the file in any path using Ionic? If so, please, share the example.

Here's the code:

downloadImage(image) {this.platform.ready().then(() => {  const fileTransfer: TransferObject = this.transfer.create();  const imageLocation = `${cordova.file.applicationDirectory}www/assets/img/${image}`;  fileTransfer.download(imageLocation, cordova.file.externalDataDirectory + image).then((entry) => {    const alertSuccess = this.alertCtrl.create({      title: `Download Succeeded!`,      subTitle: `${image} was successfully downloaded to: ${entry.toURL()}`,      buttons: ['Ok']    });    alertSuccess.present();  }, (error) => {    const alertFailure = this.alertCtrl.create({      title: `Download Failed!`,      subTitle: `${image} was not successfully downloaded. Error code: ${error.code}`,      buttons: ['Ok']    });    alertFailure.present();  });});}

Basically I want save the file in location that is visible to the user.


Viewing all articles
Browse latest Browse all 7

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>