Quantcast
Viewing all articles
Browse latest Browse all 7

Answer by fiza khan for Saving file to Downloads directory using Ionic 3

To download the File to the Download directory you need to use Cordova File and FileTransfer Plugins.

import { File } from '@ionic-native/file';import { FileTransfer } from '@ionic-native/file-transfer';constructor(private transfer: FileTransfer) { }fileTransfer: FileTransferObject = this.transfer.create();//Use your File Url and namedownloadFile(file) {  // Some Loading  this.fileTransfer.download(url, this.file.externalRootDirectory +'/Download/'+ file).then(response => {  console.log(response);  this.dismissLoading();  this.presentToast('File has been downloaded to the Downloads folder. View   it..')  })  .catch(err => {    this.dismissLoading();    console.log(err)  });}

Hope it helps.


Viewing all articles
Browse latest Browse all 7

Trending Articles