【发布时间】:2016-12-28 03:45:54
【问题描述】:
服务器端代码:
public class SomeModel
{
public Int64 Id { get; set; }
[Required]
public Int64 From_UserId { get; set; }
public string Text { get; set; }
public List<HttpPostedFileBase> Files {get; set;} //<-- Wonder if this is right way ?
}
Action Method in Controller
[HttpPost]
[Route("Upload")]
public IHttpActionResult Upload( SomeModel model)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
//More code
return Ok();
}
这样的 Angular 客户端代码可以工作吗?
$http.post("api/upload",{
Id: 1,
From_UserId: 1,
Text: "First File",
Files: [file1, file2, file3] //<-These are the ones obtained through file type input
})
附加信息:使用 Azure 存储存储上传的文件。
【问题讨论】:
-
你需要使用AngularJS上传文件吗?
标签: c# angularjs azure asp.net-web-api azure-blob-storage