Project

General

Profile

1
import {Injectable} from '@angular/core';
2
import {Observable} from 'rxjs/Observable';
3
import {CustomOptions} from './servicesUtils/customOptions.class';
4
import {HttpClient} from '@angular/common/http';
5

    
6
@Injectable()
7
export class UtilitiesService {
8
    constructor(private http: HttpClient) {
9
    }
10

    
11
    uploadPhoto(url: string, photo: File): Observable<any> {
12
        const formData = new FormData();
13
        formData.append('photo', photo);
14
        return this.http.post(url, formData, CustomOptions.getAuthOptions());
15
    }
16

    
17
    deletePhoto(url: string) {
18
        return this.http.delete(url, CustomOptions.getAuthOptions());
19
    }
20

    
21
    getTiny(url: string) {
22
        return this.http.get(url, {responseType: 'text'});
23
    }
24

    
25
}
(19-19/19)