如何使用ASP.NET MVC4 Web Api上传大文件
并获得进展?
我看到这篇文章,我知道如何处理上传的文件,但我如何获得进度数据? 如何接受文件POST
请不要发送链接上传产品.我想了解如何在MVC4 Web Api中处理这个...这里是一个处理MVC4 WebApi文件上传的示例代码
public async Task<HttpResponseMessage> Post()
{
if (Request.Content.IsMimeMultipartContent())
{
var path = HttpContext.Current.Server.MapPath("~/App_Data");
var provider = new MultipartFormDataStreamProvider(path);
await Request.Content.ReadAsMultipartAsync(provider).ContinueWith(t =>
{
if (t.IsFaulted || t.IsCanceled)
throw new HttpResponseException(HttpStatusCode.InternalServerError);
});
return Request.CreateResponse(HttpStatusCode.OK);
}
else
{
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotAcceptable, "This request is not properly formatted"));
}
}
Run Code Online (Sandbox Code Playgroud)
现在,当
await Request.Content.ReadAsMultipartAsync(provider)
Run Code Online (Sandbox Code Playgroud)
我怎样才能得到字节加载的方式?