From a13283f61ab600bcbc5cdee402f7e81a8e99868e Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Wed, 24 Aug 2022 16:30:07 -1000 Subject: [PATCH] IFormFile code update --- .../iformFile/7.0-samples/MinimalApi/Program.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/aspnetcore/fundamentals/minimal-apis/iformFile/7.0-samples/MinimalApi/Program.cs b/aspnetcore/fundamentals/minimal-apis/iformFile/7.0-samples/MinimalApi/Program.cs index 68aca797e7..11a8c8587b 100644 --- a/aspnetcore/fundamentals/minimal-apis/iformFile/7.0-samples/MinimalApi/Program.cs +++ b/aspnetcore/fundamentals/minimal-apis/iformFile/7.0-samples/MinimalApi/Program.cs @@ -1,6 +1,3 @@ -using Microsoft.AspNetCore.Http; -using System.IO; - var builder = WebApplication.CreateBuilder(args); var app = builder.Build(); @@ -8,7 +5,8 @@ app.MapGet("/", () => "Hello World!"); app.MapPost("/upload", async (IFormFile file) => { - var tempFile = Path.GetTempFileName(); // or an existing custom file path + var tempFile = Path.GetTempFileName(); + app.Logger.LogInformation(tempFile); using var stream = File.OpenWrite(tempFile); await file.CopyToAsync(stream); }); @@ -17,7 +15,8 @@ app.MapPost("/upload_many", async (IFormFileCollection myFiles) => { foreach (var file in myFiles) { - var tempFile = Path.GetTempFileName(); // or an existing custom file path + var tempFile = Path.GetTempFileName(); + app.Logger.LogInformation(tempFile); using var stream = File.OpenWrite(tempFile); await file.CopyToAsync(stream); }