The upload method doesn't trigger a controller method when Content-Type set to 'multipart/form-data'. If Content-Type set to 'application/json' method will triggered but file object will be null.
Here is my client(angular 4) implementation:
public uploader = new FileUploader({
url: "/api/mycontroller/uploadfile",
allowedFileType: ["pdf"],
headers: <Headers[]>[
//{ name: 'Content-Type', value: 'application/json' }
{ name: 'Content-Type', value: 'multipart/form-data' }
]
});
save() {
//...
this.uploader.queue.reverse()[0].upload();
}
It is my web api controller(.net core 1.0):
[Route("uploadfile")]
[HttpPost]
public async Task<ActionResult> UploadFile([FromBody]IFormFile file)
{
//...
}
Maybe I forgot to add some special parameters or something else?
I believe your Controller Method should be parameterless and you should get your file through HttpContext, I don't have a way to test it right now though, so I can't be sure... but I think it should be something like: