簡體   English   中英

如何從Web API下載以JSON FileContentResult發送的文件

[英]How to download the file sent in JSON FileContentResult from a web api

我正在從Web API獲取用於桌面應用程序的FileContentResult。

{
    "fileContents": "JVBERi0xLjMNCjEgMCBvYmoNNzQ3Ng0KJSVFT0Y=",
    "contentType": "application/octet-stream",
    "fileDownloadName": "",
    "lastModified": null,
    "entityTag": null,
    "enableRangeProcessing": false
}

是否需要知道如何下載文件?

我嘗試使用Json.Net反序列化,但拋出錯誤'未知對象類型! System.Byte”

我嘗試使用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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM