112. Update profile image service call (#13)

This commit is contained in:
Art
2021-09-12 14:48:20 +03:00
parent 135df16bee
commit bfaf21efe4
2 changed files with 11 additions and 2 deletions

View File

@ -109,7 +109,7 @@ public class UserResource {
}
@PutMapping("{username}/profileImage")
public User updateUser(@PathVariable String username, MultipartFile profileImage) {
public User updateProfileImage(@PathVariable String username, MultipartFile profileImage) {
return userService.updateProfileImage(username, profileImage);
}

View File

@ -1,6 +1,6 @@
import {Injectable} from '@angular/core';
import {environment} from "../../environments/environment";
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {HttpClient, HttpErrorResponse, HttpEvent} from "@angular/common/http";
import {Observable} from "rxjs";
import {User} from "../model/user";
@ -35,6 +35,15 @@ export class UserService {
.post<HttpResponse>(`${this.host}/user/resetPassword/${email}`, null);
}
public updateProfileImage(username: string, formData: FormData): Observable<HttpEvent<User | HttpErrorResponse>> {
return this.httpClient
.put<User | HttpErrorResponse>(`${this.host}/user/${username}/profileImage`, formData,
{
reportProgress: true,
observe: 'events'
});
}
}
export interface UserPage {