| Total Complexity | 2 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import { HttpClient } from '@angular/common/http'; |
||
| 5 | |||
| 6 | @Injectable({ |
||
| 7 | providedIn: 'root' |
||
| 8 | }) |
||
| 9 | |||
| 10 | export class FileUploadService { |
||
| 11 | |||
| 12 | private baseUrlUpload = `${environment.api+'api/uploadImage.php'+'?API_KEY='+environment.api_key}`; |
||
| 13 | |||
| 14 | private baseUrlDelete = `${environment.api+'api/deleteImage.php'+'?API_KEY='+environment.api_key}`; |
||
| 15 | |||
| 16 | constructor(private http: HttpClient) { } |
||
| 17 | |||
| 18 | uploadImage(file: File): Observable<any> { |
||
| 19 | let formData: any = new FormData(); |
||
| 20 | formData.append("image", file); |
||
| 21 | |||
| 22 | return this.http.post(this.baseUrlUpload, formData, { |
||
| 23 | reportProgress: true, |
||
| 24 | observe: "events", |
||
| 25 | }); |
||
| 26 | } |
||
| 27 | |||
| 28 | deleteImage(name: string): Observable<any> { |
||
| 29 | let formData: any = new FormData(); |
||
| 30 | formData.append("name", name); |
||
| 31 | |||
| 32 | return this.http.delete(this.baseUrlDelete, formData); |
||
| 33 | } |
||
| 35 |