我正在创建一个Web API应用程序,它在HttpResponseMessage
中向用户返回多个文件。以下是HttpResponseMessage
对象
Dim apple, banana As Byte()
apple = File.ReadAllBytes("some place")
banana = File.ReadAllBytes("some place")
Dim multiDataContent As New MultipartFormDataContent()
multiDataContent.Add(New ByteArrayContent(apple), "apple", "apple.xml")
multiDataContent.Add(New ByteArrayContent(banana), "banana", "banana.xsd")
Dim response As HttpResponseMessage = New HttpResponseMessage(HttpStatusCode.OK)
response.Content = multiDataContent
return response
我的问题是如何阅读MultipartFormDataContent
,因为返回给客户的对象是StreamContent (response.Content)
,我该如何阅读MultipartFormDataContent
?
提前致谢
答案 0 :(得分:0)
请参阅http://www.strathweb.com/2012/08/a-guide-to-asynchronous-file-uploads-in-asp-net-web-api-rtm/
重要的是,不要忘记将System.Net.Http.Formatting添加到项目中并将“Imports System.Net.Http.Formatting”添加到类中,以便您可以使用HttpContentMultipartExtensions。