-
-
Save wKoza/d10b051756badd39b418642d2006da42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const req = new HttpRequest('POST', '/upload/article', file, { | |
reportProgress: true, | |
}); | |
http.request(req).subscribe(event => { | |
// you get now access to the raw event stream. | |
if (event.type === HttpEventType.UploadProgress) { | |
// This is an upload progress event. Compute and show the % done: | |
const percentDone = Math.round(100 * event.loaded / event.total); | |
console.log(`File is ${percentDone}% uploaded.`); | |
} else if (event instanceof HttpResponse) { | |
console.log('File is completely uploaded!'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment