I`m working on my project that uses sql as data base and asp.net web-api with entity framework. I uploaded into the sql table image as varbinary(MAX) and then converted it into image in the web-api. now how can I get that image with angular 8 ?
The get method:
[Route("api/images/{ID}")]
public Image GetImage(int ID)
{
var selectedimg = db.imges.FirstOrDefault(s => s.id ==ID);
MemoryStream ms = new MemoryStream(selectedimg.pic);
Image returnImage = Image.FromStream(ms);
return returnImage;
}
ts component:
constructor(private http:HttpClient ) {
}
image:any;
ngOnInit(){
this.http.get("https://localhost:44355/api/images/1").subscribe(data=>this.image=data);
};
html:
<img [src]="image" >