我正在向 WCF 服务发送一条包含文件名和 base64 编码图像的 JSON 消息。我不太确定如何将其转换回图像,更具体地说是反序列化返回流。
WCF 接口
[OperationContract]
[WebInvoke(
Method = "POST",
UriTemplate = "/UploadImage", ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
string UploadImage(Stream image);
以及消息的某些部分(我将其保存到文件中,以便查看并尝试理解)
--hr56lXG6Q_hKg5opmTx4xejr28dU17AC
Content-Disposition: form-data; name="entity"
{"filename":"mypicture.jpg","thebigfile":"\/9j\/4Re6RXhpZgAATU0AKgAAAAgACwEPAAIAAAAOAAAAkgEQAAIAAAAGAAAAoAESAAMAAAABAAYAAAEaAAUAAAABAAAApgEbAAUAAAABAAAArgEoAAMAAAABAAIAAAExAAIAAAATAAAAtgEyAAIAAAAUAAAAygITAAMAAAABAAEAAIdpAAQAAAABAAAA3oglAAQAAAABAAACegAAAoBTb255IEVyaWNzc29uAExUMjZpAAAAAEgAAAABAAAASAAAAAE2LjEuQS4yLjQ1XzUzX2YxMDAApDIwMTI6MTA6MDYgMDk6MzI6MTcAABiCmgAF
and lots more of the base64 encoded image....
--hr56lXG6Q_hKg5opmTx4xejr28dU17AC--
我如何反序列化这个?流是要走的路吗?我不只是想删除最上面的行然后开始反序列化 JSON 数组,我想知道为什么它看起来像这样。