HttpContent:从HttpResponse中提取多部分/ MIME [英] HttpContent: pulling multipart/MIME out of a HttpResponse

查看:120
本文介绍了HttpContent:从HttpResponse中提取多部分/ MIME的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从Metro应用程序中搜索扫描作业的Web服务(WSD /扫描),并在发送最终(RetrieveImage)SOAP信封后从HttpClient接收到Response对象。正如预期的那样,响应是多部分/ MIME响应。我需要
现在需要的是获取jpeg图像流的 那个回应。

I'm hitting a web service (WSD/scan) for a scan job out of a Metro app, and have received a Response object from the HttpClient after sending the final (RetrieveImage) SOAP envelope. Response is, as expected a multipart/MIME response. What I need to do now is get the jpeg image stream out of  that response.

HttpResponse.Content.ReadAsStringAsync() 向我展示了两个收到的项目:application / xop + xml(响应SOAP信封)和image / jpeg。

HttpResponse.Content.ReadAsStringAsync() shows me two items received: application/xop+xml (the response SOAP envelope), and image/jpeg.

HttpResponse.Content.GetType()。FullName报告它是一个StreamContent。

HttpResponse.Content.GetType().FullName reports that it is a StreamContent.

我可以将内容转换为StreamContent,并将流提取为字节数组,但它是完整内容,而不仅仅是我之后的JPEG。

I can typecast Content as StreamContent, and extract the stream into a byte array, but it is the full content, not just the JPEG I'm after.

我假设我可以解析字节数组,找到JPEG数据的开头和结尾,并提取它,但是有没有办法将HttpContent发送回来并将其转换为MultipartFormsContent(这是定制的) for multipart / MIME)?或者其他一些
和更简洁的方法来识别jpeg流?

I suppose I can parse the byte array, find the begin and end of the JPEG data, and extract that, but is there a way to take the HttpContent sent back and get it into a MultipartFormsContent (which is tailored for multipart/MIME)? Or some other and cleaner way to identify the jpeg stream?

手动解析流的开始和停止似乎是遇到意外后果的好方法。

Manually parsing the stream for start and stop seems like a good way to encounter unexpected consequences.

推荐答案

这是一个非常好的问题。 我将在本周开展工作。
That's a really good question.  I'll work on it this week.


这篇关于HttpContent:从HttpResponse中提取多部分/ MIME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆