Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: [FromForm(Name = "file")] parameter #3055

Open
Lean365 opened this issue Aug 29, 2024 · 2 comments
Open

[Bug]: [FromForm(Name = "file")] parameter #3055

Lean365 opened this issue Aug 29, 2024 · 2 comments
Labels
bug needs-repro A minimal reproducible example is needed

Comments

@Lean365
Copy link

Lean365 commented Aug 29, 2024

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

@Lean365 Lean365 added the bug label Aug 29, 2024
@martincostello
Copy link
Collaborator

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.

@martincostello martincostello added the needs-repro A minimal reproducible example is needed label Aug 29, 2024
@Tri125
Copy link

Tri125 commented Oct 9, 2024

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs-repro A minimal reproducible example is needed
Projects
None yet
Development

No branches or pull requests

3 participants