openaire-library/services/utilities.service.ts

28 lines
746 B
TypeScript

import {Injectable} from '@angular/core';
import {Observable} from 'rxjs';
import {CustomOptions} from './servicesUtils/customOptions.class';
import {HttpClient} from '@angular/common/http';
@Injectable({
providedIn: "root"
})
export class UtilitiesService {
constructor(private http: HttpClient) {
}
uploadPhoto(url: string, photo: File): Observable<any> {
const formData = new FormData();
formData.append('photo', photo);
return this.http.post(url, formData, CustomOptions.getAuthOptions());
}
deletePhoto(url: string) {
return this.http.delete(url, CustomOptions.getAuthOptions());
}
getTiny(url: string) {
return this.http.get(url, {responseType: 'text'});
}
}