blob: 8b9d0a3b5c124a050bcf4582271903f58adff458 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Guid } from 'guid-typescript';
import { Observable } from 'rxjs';
import { AppConstants } from '../app-constants.module';
import { TokenService } from './token.service';
@Injectable({
providedIn: 'root'
})
export class ProfilePictureService {
constructor(private _http: HttpClient, private _tokenService: TokenService)
{ }
putPictureWithSessionStorageRequest(newPicture: File): Observable<object> {
const userId = this._tokenService.getUserIdFromSessionStorageToken();
const token = this._tokenService.getTokenFromSessionStorage();
return this.putRatingRequest(userId, token, newPicture);
}
putRatingRequest(userId: Guid, authToken: string, newPicture: File): Observable<object> {
const options = {
params: new HttpParams().set('UserId', userId.toString()),
headers: new HttpHeaders().set('Authorization', 'Bearer ' + authToken)
};
const form = new FormData();
form.append('picture', newPicture);
return this._http.put(AppConstants.API_PROFILE_PICTURE_URL, form, options);
}
}
|