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

Answer by bambaniasz for Saving file to Downloads directory using Ionic 3

$
0
0

the problem was lack of permission. Here is the working code that can download file to downloads directory:

async downloadFile() {  await this.fileTransfer.download("https://cdn.pixabay.com/photo/2017/01/06/23/21/soap-bubble-1959327_960_720.jpg", this.file.externalRootDirectory +'/Download/'+"soap-bubble-1959327_960_720.jpg");}getPermission() {  this.androidPermissions.hasPermission(this.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE)    .then(status => {      if (status.hasPermission) {        this.downloadFile();      }       else {        this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE)          .then(status => {            if(status.hasPermission) {              this.downloadFile();            }          });      }    });}

Viewing all articles
Browse latest Browse all 7


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