The official documentation covers uploading files and posting form inputs.
https://learn.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads?view=aspnetcore-9.0
First, define a model that matches the fields you wish to upload.
public class UploadModel
{
public IFormFile? TifFile { get; set; }
public string HostName { get; set; } = string.Empty;
public string AccessCode { get; set; } = string.Empty;
}
Add the model type in the action signature. Finally, add the [FromForm] attribute to let the action know it should expect a content type of multipart/form-data.
[Route("api/[controller]")]
[ApiController]
public class FileUploadController : ControllerBase
{
[HttpPost]
public IActionResult awsUploadAsync([FromForm] UploadModel model)
{
return Ok(model);
}
}