From 40d91c8d8493c13790a6edacd8d4af8269cb05c7 Mon Sep 17 00:00:00 2001 From: Lisoveliy Date: Tue, 8 Jul 2025 15:07:12 +0300 Subject: [PATCH] feat: fixed upload --- HTTP2FileStreams.csproj | 4 ++++ Program.cs | 1 + UploadController.cs | 6 ++---- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/HTTP2FileStreams.csproj b/HTTP2FileStreams.csproj index bc4fb70..e6bf24d 100644 --- a/HTTP2FileStreams.csproj +++ b/HTTP2FileStreams.csproj @@ -12,4 +12,8 @@ + + + + diff --git a/Program.cs b/Program.cs index b2f90e9..09455c1 100644 --- a/Program.cs +++ b/Program.cs @@ -13,6 +13,7 @@ public class Program { endpointOptions.Protocols = HttpProtocols.Http2; }); + options.Limits.MaxRequestBodySize = null; }); builder.Services.AddControllers(); diff --git a/UploadController.cs b/UploadController.cs index 5e20f6f..cf17a4b 100644 --- a/UploadController.cs +++ b/UploadController.cs @@ -7,17 +7,15 @@ namespace HTTP2FileStreams; public class UploadController : ControllerBase { [HttpPost] - [DisableFormValueModelBinding] // Отключаем стандартный парсинг формы + [DisableFormValueModelBinding] public async Task Upload() { - // Получаем имя файла из заголовка var fileName = Request.Headers["X-File-Name"].ToString(); if (string.IsNullOrEmpty(fileName)) return BadRequest("File name header is missing"); fileName = Uri.UnescapeDataString(fileName); - - // Потоковая запись файла + if (!Directory.Exists("Uploads")) Directory.CreateDirectory("Uploads");