Skip to content

Instantly share code, notes, and snippets.


wKoza/upload.ts Secret

Created Aug 10, 2017
What would you like to do?
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 /;
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