我有一个问题,如何从Azure函数的多部分响应接收数据
我有一个同时下载数据+ N个文件内容的案例。
作为响应,我得到了JSON数据+
{
"headers": [
{
"key": "Content-Type",
"value": [
"application/octet-stream"
]
},
{
"key": "Content-Disposition",
"value": [
"form-data; name=\"files\"; filename=\"file\""
]
}
]
},
但我没办法下载
我的代码
MultipartContent content = new MultipartContent("mixed", "----Boundary");
content.Add(JsonContent.Create(result, new MediaTypeHeaderValue("application/json")));
foreach (var result1 in result)
{
foreach (var room in result1.Rooms)
{
var plan = room.// Something
WebClient webClient = new WebClient();
var filedata = await webClient.DownloadDataTaskAsync(new Uri(plan .FileUrl));
MemoryStream stream = new MemoryStream();
stream.Write(filedata, 0, filedata.Length);
var fileContent = new StreamContent(stream);
fileContent.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "\"files\"",
FileName = "\"" + plan.FileName + "\""
};
content.Add(fileContent);
}
}
return new OkObjectResult(content);
有变通办法吗?也许我不明白什么
1条答案
按热度按时间unhi4e5o1#
我的函数.cs:-
输出:-
具有多部分内容逻辑:-
输出:-