Ejemplo n.º 1
0
        public HttpResponseMessage GetArticleImage(string imgid)
        {
            string path = Comercial.GetArtigoImagePath(imgid);

            if (path == null)
            {
                throw new HttpResponseException(
                          Request.CreateResponse(HttpStatusCode.NotFound));
            }
            else
            {
                Image        img = Image.FromFile(path);
                MemoryStream ms  = new MemoryStream();
                img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
                result.Content = new ByteArrayContent(ms.ToArray());
                result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpg");
                return(result);
            }
        }