开发者

Send Image as http response

开发者 https://www.devze.com 2023-04-12 13:57 出处:网络
I am downloading bytes from a URL link ( which is a link to pdf file) WebClient imageWebClient = new WebClient();

I am downloading bytes from a URL link ( which is a link to pdf file)

WebClient imageWebClient = new WebClient();
response.Image = imageWebClient.DownloadData(Url);

for other images types I am doing following, I am not sure how am I supposed to show this image which is extracted from a pdf file.

context.Response.AddHeader("Content-Disposition",开发者_JS百科 "inline;  filename=image.jpg");
                            context.Response.ContentType = "image/jpeg";

streamBitmap = new MemoryStream(response.Image);  //GetBitMapStreamFromData(CheckImg.ImageData);
if (streamBitmap != null)
{
    streamBitmap.WriteTo(context.Response.OutputStream);
}

This doesn't work for bytes received by above code from a pdf link.

0

精彩评论

暂无评论...
验证码 换一张
取 消