Project

General

Profile

1 55945 k.triantaf
import {Injectable} from '@angular/core';
2
import {Observable} from 'rxjs/Observable';
3
import {CustomOptions} from './servicesUtils/customOptions.class';
4 55964 argiro.kok
import {HttpClient} from '@angular/common/http';
5 55945 k.triantaf
6 59486 k.triantaf
@Injectable({
7
    providedIn: "root"
8
})
9 56013 k.triantaf
export class UtilitiesService {
10 55945 k.triantaf
    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 55964 argiro.kok
        return this.http.post(url, formData, CustomOptions.getAuthOptions());
17 55945 k.triantaf
    }
18
19
    deletePhoto(url: string) {
20 55964 argiro.kok
        return this.http.delete(url, CustomOptions.getAuthOptions());
21 55945 k.triantaf
    }
22
23 56013 k.triantaf
    getTiny(url: string) {
24
        return this.http.get(url, {responseType: 'text'});
25
    }
26
27 55945 k.triantaf
}