2019-06-02 20:52:26 +02:00
|
|
|
import {Injectable} from '@angular/core';
|
|
|
|
import {Observable} from 'rxjs/Observable';
|
|
|
|
import {CustomOptions} from './servicesUtils/customOptions.class';
|
2019-06-03 15:20:36 +02:00
|
|
|
import {HttpClient} from '@angular/common/http';
|
2019-06-02 20:52:26 +02:00
|
|
|
|
|
|
|
@Injectable()
|
2019-06-06 12:51:39 +02:00
|
|
|
export class UtilitiesService {
|
2019-06-02 20:52:26 +02:00
|
|
|
constructor(private http: HttpClient) {
|
|
|
|
}
|
|
|
|
|
|
|
|
uploadPhoto(url: string, photo: File): Observable<any> {
|
|
|
|
const formData = new FormData();
|
|
|
|
formData.append('photo', photo);
|
2019-06-03 15:20:36 +02:00
|
|
|
return this.http.post(url, formData, CustomOptions.getAuthOptions());
|
2019-06-02 20:52:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
deletePhoto(url: string) {
|
2019-06-03 15:20:36 +02:00
|
|
|
return this.http.delete(url, CustomOptions.getAuthOptions());
|
2019-06-02 20:52:26 +02:00
|
|
|
}
|
|
|
|
|
2019-06-06 12:51:39 +02:00
|
|
|
getTiny(url: string) {
|
|
|
|
return this.http.get(url, {responseType: 'text'});
|
|
|
|
}
|
|
|
|
|
2019-06-02 20:52:26 +02:00
|
|
|
}
|