diff --git a/projects/ucap-webmessenger-api-common/src/lib/services/common-api.service.ts b/projects/ucap-webmessenger-api-common/src/lib/services/common-api.service.ts index 6d0b0e29..327735f8 100644 --- a/projects/ucap-webmessenger-api-common/src/lib/services/common-api.service.ts +++ b/projects/ucap-webmessenger-api-common/src/lib/services/common-api.service.ts @@ -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 { - return this.httpClient - .post( - !!fileTalkSaveUrl - ? fileTalkSaveUrl - : this.moduleConfig.urls.fileTalkSave, - {}, - { - params: encodeFileTalkSave(req) + ): Observable { + 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(