Skip to content

Commit

Permalink
doc: Improve progressEvent documentation (apache#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
breautek authored Sep 23, 2020
1 parent 4a1e766 commit 24b15c5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,17 @@ var headers={'headerParam':'headerValue', 'headerParam2':'headerValue2'};
options.headers = headers;

var ft = new FileTransfer();
var progressValue = 0;
ft.onprogress = function(progressEvent) {
if (progressEvent.lengthComputable) {
loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
// Calculate the percentage
progressValue = progressEvent.loaded / progressEvent.total;
} else {
loadingStatus.increment();
progressValue++;
}

// Display percentage in the UI
document.getElementByID('progress-value').innerHTML = progressValue;
};
ft.upload(fileURL, uri, win, fail, options);
```
Expand Down

0 comments on commit 24b15c5

Please sign in to comment.