【发布时间】:2018-07-11 10:07:39
【问题描述】:
我的 azure 函数接收大型视频文件和图像并将其存储在 Azure blob 中。客户端 API 将数据分块发送到我的 Azure htttp 触发器函数。我是否必须在接收端做一些事情来提高性能,比如分块接收数据?
Bruce,实际上客户端代码正在由其他团队开发。现在我正在通过邮递员对其进行测试并从多部分 http 请求中获取文件。
foreach (HttpContent ctnt in provider.Contents) {
var dataStream = await ctnt.ReadAsStreamAsync();
if (ctnt.Headers.ContentDisposition.Name.Trim().Replace("\"", "") == "file")
{
byte[] ImageBytes = ReadFully(dataStream);
var fileName = WebUtility.UrlDecode(ctnt.Headers.ContentDisposition.FileName);
} }
ReadFully 函数
public static byte[] ReadFully(Stream input){
using (MemoryStream ms = new MemoryStream())
{
input.CopyTo(ms);
return ms.ToArray();
}}
【问题讨论】:
-
您能否共享客户端代码 sn-p 用于分块上传数据,以及用于将文件上传到 blob 存储的 azure 函数中的当前代码?我假设你可以做一些额外的设置,并在你的 azure 函数中将文件并行上传到你的 blob 存储以提高性能。
标签: c# .net azure asp.net-web-api chunking