Project

General

Profile

1 61381 k.triantaf
import {Injectable} from '@angular/core';
2
import {Observable} from 'rxjs';
3
import {CustomOptions} from './servicesUtils/customOptions.class';
4
import {HttpClient} from '@angular/common/http';
5
6
@Injectable({
7
    providedIn: "root"
8
})
9
export class UtilitiesService {
10
    constructor(private http: HttpClient) {
11
    }
12
13
    uploadPhoto(url: string, photo: File): Observable<any> {
14
        const formData = new FormData();
15
        formData.append('photo', photo);
16
        return this.http.post(url, formData, CustomOptions.getAuthOptions());
17
    }
18
19
    deletePhoto(url: string) {
20
        return this.http.delete(url, CustomOptions.getAuthOptions());
21
    }
22
23
    getTiny(url: string) {
24
        return this.http.get(url, {responseType: 'text'});
25
    }
26
27
}