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

app.MapPost("/fileUp", async (IFormFile file) #8

Closed
Rick-Anderson opened this issue Jul 15, 2022 · 7 comments
Closed

app.MapPost("/fileUp", async (IFormFile file) #8

Rick-Anderson opened this issue Jul 15, 2022 · 7 comments

Comments

@Rick-Anderson
Copy link
Contributor

See https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-net-7-preview-1/
Put in https://github.com/dotnet/AspNetCore.Docs.Samples/tree/main/fundamentals/minimal-apis/samples/IFormFile

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/", () => "Hello World!");

app.MapPost("/fileUp", async (IFormFile file) =>
{
    string tempfile = Path.GetTempFileName();
    using var stream = File.OpenWrite(tempfile);
    await file.CopyToAsync(stream);
});

app.MapPost("/FilesUp", async (IFormFileCollection myFiles) =>
{
    foreach (var file in myFiles)
    {
        string tempfile = Path.GetTempFileName();
        using var stream = File.OpenWrite(tempfile);
        await file.CopyToAsync(stream);
    }
});

app.Run();

Update readme.txt with instructions on testing.

@Rick-Anderson
Copy link
Contributor Author

cc @sammychinedu2ky

@sammychinedu2ky
Copy link
Contributor

ok on it

@sammychinedu2ky
Copy link
Contributor

IFormFileCollection seems to work for me but IFormFile has issues binding data

@Rick-Anderson
Copy link
Contributor Author

IFormFileCollection seems to work for me but IFormFile has issues binding data

Call out that code when you create a PR and we'll have the experts review.

@sammychinedu2ky
Copy link
Contributor

sammychinedu2ky commented Jul 15, 2022 via email

@Rick-Anderson
Copy link
Contributor Author

It's done and documented here.

@sammychinedu2ky
Copy link
Contributor

It's done and documented here.

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants