更新时间:2022-12-07 22:02:41
你可以通过使用像这样的onProgress函数来显示progressBar
You can show progressBar by using onProgress function like this
public fileTransfer: TransferObject = this.transfer.create();
public upload(path,folder)
{
url="http://www.axmag.com/download/pdfurl-guide.pdf";
var trustHosts = true;
this.presentLoading("Loading");
//**Progress Bar**
this.fileTransfer.onProgress((e)=>
{
let prg=(e.lengthComputable) ? Math.round(e.loaded / e.total * 100) : -1;
console.log("progress:"+prg);
});
this.fileTransfer.upload(file_path, api_endpoint, options, data).then((entry) => {
//handle success
console.log('upload complete: ' );
},
(error) => {
this.loader.dismiss();
alert('uploading faild: ');
console.log(error);
//handle error
});
}
现在你可以调用upload()函数来上传文件
Now you can call upload() function to upload a file