Hello,
I am using FileTransferObject to download a file from server. I am successfully downloading file from the server, but I am not able to listen OnProgress event. Following is my code:-
return new Promise((resolve, reject) => {
this.fileTransfer.onProgress = function (progressEvent) {
console.log('progress');
console.log(progressEvent);
if (progressEvent) {
this.downloadProgress = Math.floor((progressEvent.loaded / progressEvent.total) * 100);
this.episodeDownloadProgress[feedId].progress = this.downloadProgress;
}
};
this.fileTransfer.download(encodeURI(url), path).then(entry => {
this.episodeDownloadProgress[feedId].status = "downloaded";
resolve(entry);
}).catch(error => {
this.utility.presentToast('Donwload error');
reject(error);
})
});
Please let me know if anything I am doing wrong.
Thank you in advanced.
My solution to this:
this.fileTransfer.onProgress((progressEvent) => {
console.log(progressEvent);
if (progressEvent.lengthComputable) {
var perc = Math.floor(progressEvent.loaded / progressEvent.total * 100);
status.innerHTML = perc + "% loaded...";
} else {
if (status.innerHTML == "") {
status.innerHTML = "Loading";
} else {
status.innerHTML += ".";
}
}
});
@kishorebhagya It did work with your solution. Thank you :)
how can i do this on ionic5? Could you show me how I can integrate this with the progress bar in ionic?
Most helpful comment
My solution to this: