I am developing a controller in ASP.NET Core 6.0 and I want to implement a post consumer that accept binary images.
If I write the signature in this way:
[HttpPost("image/{pv}/{articolo}"), 
 Consumes("image/jpeg", new string[] { "image/jpg", "image/png", "image/tiff", "image/tif" }),
 SwaggerResponse(StatusCodes.Status200OK), 
 SwaggerResponse(StatusCodes.Status400BadRequest, "nel caso in cui PV o articolo non esistono")]
public async Task<IActionResult> postImage(string pv, string articolo, [FromBody] Stream fileStream)
{ 
    /* use fileStream to save into disk*/ 
}
The swagger works great:
But If I try it returns error 415 "Unsupported Media Type"
I tried removing [FromBody], the only way to not get 415 is remove the parameter and use Request.Body, but I need the swagger as documentation.