[英]How to download the file sent in JSON FileContentResult from a web api
I am a getting a FileContentResult from a web API for my desktop application. 我正在从Web API获取用于桌面应用程序的FileContentResult。
{
"fileContents": "JVBERi0xLjMNCjEgMCBvYmoNNzQ3Ng0KJSVFT0Y=",
"contentType": "application/octet-stream",
"fileDownloadName": "",
"lastModified": null,
"entityTag": null,
"enableRangeProcessing": false
}
Need to know how the file can be downloaded? 是否需要知道如何下载文件?
I tried deserializing using Json.Net but it throws error 'Unknown object type! 我尝试使用Json.Net反序列化,但抛出错误'未知对象类型! System.Byte'
System.Byte”
Instead of Json.Net I tried with Newtonsoft.Json, with below code I was able to download the file. 我尝试使用Newtonsoft.Json而不是Json.Net,并使用下面的代码下载了文件。
Dim fcr As System.Web.Mvc.FileContentResult
fcr = Newtonsoft.Json.JsonConvert.DeserializeObject(Of System.Web.Mvc.FileContentResult)(json_string)
File.WriteAllBytes("e:\test.pdf", fcr.FileContents)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.