I have Angular 2 client that download a file from rest service:
downloadAPK(projectName: string): void {
this.projectService.downloadAppFile(projectName).subscribe(blobContent => {
var a = document.createElement("a");
a.setAttribute('style', 'display:none;');
document.body.appendChild(a);
var url = window.URL.createObjectURL(blobContent);
a.href = url;
a.download = projectName + '.apk';
a.click();
});
}
The Client code:
<div class="subTitleStatus">Ready
<a style="cursor:pointer" (click)="downloadAPK(project.name)"><i class="glyphicon glyphicon-download-alt"></i></a>
</div>
The Service code:
downloadAppFile(projectName: String): any {
return this._http.get(this._productUrl + "/downloadAppFile/" + projectName,
{responseType: ResponseContentType.Blob})
.map(res => res.blob())
.catch(this.handleError);
}
The problem is that the user does not have any indication that the download started until the client finish downloading the file. i'm talking about huge files
how can i change the client code to show downloading percentage when the user click the download link until finish downloading?
Thanks