progress of file upload is added
This commit is contained in:
parent
9ae1ed25c4
commit
a880e89ba4
|
@ -1,5 +1,11 @@
|
|||
import { Injectable, Inject } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import {
|
||||
HttpClient,
|
||||
HttpEventType,
|
||||
HttpResponse,
|
||||
HttpRequest,
|
||||
HttpProgressEvent
|
||||
} from '@angular/common/http';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
@ -109,18 +115,23 @@ export class CommonApiService {
|
|||
public fileTalkSave(
|
||||
req: FileTalkSaveRequest,
|
||||
fileTalkSaveUrl?: string
|
||||
): Observable<FileTalkSaveResponse> {
|
||||
return this.httpClient
|
||||
.post<any>(
|
||||
!!fileTalkSaveUrl
|
||||
? fileTalkSaveUrl
|
||||
: this.moduleConfig.urls.fileTalkSave,
|
||||
{},
|
||||
{
|
||||
params: encodeFileTalkSave(req)
|
||||
): Observable<FileTalkSaveResponse | HttpProgressEvent> {
|
||||
const httpReq = new HttpRequest(
|
||||
'POST',
|
||||
!!fileTalkSaveUrl ? fileTalkSaveUrl : this.moduleConfig.urls.fileTalkSave,
|
||||
encodeFileTalkSave(req),
|
||||
{ reportProgress: true }
|
||||
);
|
||||
|
||||
return this.httpClient.request(httpReq).pipe(
|
||||
map(event => {
|
||||
if (event instanceof HttpResponse) {
|
||||
return decodeFileTalkSave(event);
|
||||
} else if (HttpEventType.UploadProgress === event.type) {
|
||||
return event;
|
||||
}
|
||||
)
|
||||
.pipe(map(res => decodeFileTalkSave(res)));
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
public fileTalkShare(
|
||||
|
|
Loading…
Reference in New Issue
Block a user