Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [HttpGet]
- [Route("api/books/picture/{id}")]
- public HttpResponseMessage GetPicture(int id)
- {
- var data = _repository.Get(id);
- if (data != null)
- {
- byte[] imgData = data.ImageOfBook;
- MemoryStream ms = new MemoryStream(imgData);
- HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StreamContent(ms) };
- response.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png");
- return response;
- }
- return Request.CreateResponse(HttpStatusCode.NotFound, "Not Found");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement