apache / cordova-plugin-file-transfer

Apache Cordova File Transfer Plugin
https://cordova.apache.org/
Apache License 2.0
595 stars 888 forks source link

OnProgress event waits for full file download before reflecting the percentage of file downloaded #257

Closed akashdeepsharma1991 closed 3 years ago

akashdeepsharma1991 commented 4 years ago

Bug Report

The onprogress method is showing the percentage properly in console.log. But when i am binding it to html It waits till whole file is download and the increase the progress too 100

Problem

What is expected to happen?

Should update the html view as the file download progressive

What does actually happen?

Information

Command or Code

 const url = 'http://mirrors.standaloneinstaller.com/video-sample/jellyfish-25-mbps-hd-hevc.3gp';
    this.fileTransfer.download(url, this.file.dataDirectory + 'jellyfish-25-mbps-hd-hevc.3gp').then((entry) => {
      console.log('download complete: ' + entry.toURL());
    }, (error) => {
      // handle error
    });
    let _this = this;
    this.fileTransfer.onProgress((progressEvent) => {
      // console.log(progressEvent,'progressEvent');
      let perc = Math.floor(progressEvent.loaded / progressEvent.total * 100);
      // perc = perc/100;
      console.log('perc',perc);
      item.progressValue = perc;
      console.log(item.progressValue);

    });

Environment, Platform, Device

Version information

Checklist

breautek commented 3 years ago

This plugin has no opinion on the UI. It simply just fires progress events, which as you say works.

In the example, the 3gp file is an extremely small file (300 bytes) so chances are the progress event it simply firing several times and finishes downloading before the next render.