I can understand using IFormFile
to upload files in an MVC web app but what is the correct method of uploading files using ASP.NET Core when writing an API supporting Swagger?
[HttpPost("{id}/content", Name ="PostZipFile")]
[Consumes("application/zip")]
public Task<IActionResult> PostZipFile(int id, [FromBody] IFormFile zipFile)
{
}
[HttpPost("{id}/content", Name ="PostZipFile")]
[Consumes("application/zip")]
public Task<IActionResult> PostZipFile(int id)
{
this.Response.Body.Stream
}
Try this :
[HttpPost("{id}/content", Name ="PostZipFile")]
public Task<IActionResult> PostZipFile(int id,IFormFile zipFile)
{
}
And make sure that on the Client Side, the Form Action or Ajax request has: encoding type= "multipart/form-data"