C☭
Size: a a a
C☭
c
c
const req = new HttpRequest('POST', '/upload/file', file, {
reportProgress: true,
});
c
C☭
C☭
J💖
c
c
c
c
c
C☭
c
VS
VS
uploadPayrolls(files: File[], payrollDocId: string) {
const formData = new FormData();
files.forEach(file => {
formData.append('files', file);
});
return this.http.post(
`${this.apiUrl}/payrolls/upload`,
formData,
{
params: { payrollDocId },
reportProgress: true,
observe: 'events'
}
).pipe(
distinctUntilChanged(),
map(this.processProgress)
);
}
processProgress(event) {
switch (event.type) {
case HttpEventType.UploadProgress:
const progress = Math.round(100 * event.loaded / event.total);
return { status: 'progress', progress };
case HttpEventType.Response:
return event.body;
default:
return `Unhandled event: ${event.type}`
}
}
c