-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Support binding to IFormFile in minimal routing APIs #34303
Comments
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
The below API would be good too, to handle more than one file at a time.
|
I worked this up today in my side-by-side comparison solution and was sad to come across this feature parity gap. Whilst this works fine with Web API: [HttpPost]
[Route("/upload")]
public async Task UploadFile(IFormFile file, CancellationToken token)
{
using (var stream = System.IO.File.OpenWrite("upload.txt"))
{
await file.CopyToAsync(stream);
}
} A similar approach fails to work in minimal API: app.MapPost("/upload", async(IFormFile file, CancellationToken token) =>
{
using (var stream = System.IO.File.OpenWrite("upload.txt"))
{
await file.CopyToAsync(stream);
}
}); I'd like to see how we get to party. Or maybe add an analyzer when folks do this to provide guidance to the alternative approach in this issue. |
@jchannon We would support The other thing missing here is The other piece of work is updating the API explorer to set the right request content type if we support file upload. |
Would it also make sense to support |
I've put up a draft to try and get this working in #35158. |
We didn't do forms because we haven't thought the CSRF/Antiforgery features |
@halter73 This is done right? |
Thanks for contacting us. We're moving this issue to the |
@davidfowl Yep PR was merged a few weeks ago. I was going to do some E2E validation on it with Swagger to check it over, but the installer repo's been a bit sad over the last few weeks ingesting the SDK for 7. |
Is your feature request related to a problem? Please describe.
Today we don't have any native support for binding to IFormFiles as part of the incoming request. This is convenient for applications that want to do file uploads.
Describe the solution you'd like
Additional context
Without this, it will look like this:
The text was updated successfully, but these errors were encountered: