我能够下载文件到下面的脚本设备。我想知道的是能够显示在视图中下载的百分比。
downloadImage() {
this.platform.ready().then(() => {
const fileTransfer: FileTransferObject = this.Transfer.create();
const audiolocation = `http://myweb.com/files`+this.audio_download;
fileTransfer.download(audiolocation, this.storageDirectory+'downloads').then((entry) => {
const alertSuccess = this.alertCtrl.create({
title: `Download Succeeded!`,
subTitle: `Audio was successfully downloaded to: ${entry.toURL()}`,
buttons: ['Ok']
});
alertSuccess.present();
}, (error) => {
const alertFailure = this.alertCtrl.create({
title: `Download Failed!`,
subTitle: `was not successfully downloaded. Error code: ${error.code}`,
buttons: ['Ok']
});
alertFailure.present();
});
});
}
3条答案
按热度按时间yeotifhr1#
文件传输具有onProgress方法。请参考此link
希望这个有用。
jum4pzuy2#
更像是这样:
elcex8rz3#
.ts文件:
.html文件: