Un début d'ajout pour uploader des images

This commit is contained in:
Sébastien André
2020-05-26 19:10:25 +02:00
parent f21bda7d7b
commit 6ea906f80f
8 changed files with 165 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { Observable } from "rxjs";
import { ImageResp, ImageReq } from "../models/Image";
import { BaseService } from "./base.service";
@Injectable()
export class ImageService extends BaseService {
constructor(private http: HttpClient) {
super();
}
public getListOfImages(): Observable<Array<ImageResp>> {
return this.http.get<Array<ImageResp>>(`${this.apiUrl}/Image`, {
headers: this.headers,
});
}
public AddImage(commentImg: string, dataImg: File) {
const bodyNewImage: ImageReq = {
id: 0,
comment: commentImg,
data: dataImg.type,
};
this.http
.post(`${this.apiUrl}/Image`, bodyNewImage, {
headers: this.headers,
})
.subscribe((data) => console.log(data));
}
}