[Bug]: [FromForm(Name = "file")] parameter
Opened this issue · 2 comments
Describe the bug
When using the [FromForm(Name = "file")] parameter, the swagger error code is as follows.
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
{
List<MmMarbDto> list = new();
using (var stream = formFile.OpenReadStream())
{
list = stream.Query<MmMarbDto>(startCell: "A1").ToList();
}
return SUCCESS(_MmMarbService.ImportMmMarb(list.Adapt<List<MmMarb>>()));
}
08-29 10:51:08|::1|0HN67QLM2IATC|http://localhost/swagger/routine/swagger.json
Failed to generate Operation for action - Ams.WebApi.Controllers.Routine.InstCorpController.ImportData (Ams.WebApi). See inner exception
public IActionResult ImportData(IFormFile formFile)//[FromForm(Name = "file")]
{
List<MmMarbDto> list = new();
using (var stream = formFile.OpenReadStream())
{
list = stream.Query<MmMarbDto>(startCell: "A1").ToList();
}
return SUCCESS(_MmMarbService.ImportMmMarb(list.Adapt<List<MmMarb>>()));
}
Swagger is normal when not in use.
6.5 The following versions are normal using [FromForm(Name = "file")].
Expected behavior
No response
Actual behavior
No response
Steps to reproduce
No response
Exception(s) (if any)
No response
Swashbuckle.AspNetCore version
V6.6.1~6.7.3
.NET Version
net 8.0
Anything else?
No response
Please provide a minimal reproducible example as a GitHub repository that demonstrates the issue you're experiencing so we can look into this further.
The code snippet as-written isn't particularly useful for debugging as it references code you haven't provided.
Also provide details of the inner exception mentioned in the error, particularly its stack trace.
@Lean365
From v6.6.x and onward Swashbuckle will throw an error when a user uses FromForm attribute with IFormFile in controller methods.
Have a look at this documentation for more information :
Handle Forms and File Uploads