My server uses .Net Core 2.1.402
Here is my C# class:
public class SampleDetailsDto
{
public Guid Id{ get; set; }
public string Text { get; set;
Use IFormFile
and [FromForm]
and do not access the request to extract files.
Angular code:
public sendFiles(files: File[], [...]): Observable {
const formData = new FormData();
formData.append('files', files); // add all the other properties
return this.http.post('http://somehost/someendpoint/fileupload/', formData);
}
ASP.NET Core code:
public class MyFileUploadClass
{
public IFormFile[] Files { get; set; }
// other properties
}
[HttpPost("fileupload")]
public async Task FileUpload([FromForm] MyFileUploadClass @class) // -> property name must same as formdata key
{
// do the magic here
return NoContent();
}