feat: fixed upload

This commit is contained in:
Pavel-Savely Savianok 2025-07-08 15:07:12 +03:00
parent 0d35453628
commit 40d91c8d84
3 changed files with 7 additions and 4 deletions

View File

@ -12,4 +12,8 @@
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="Uploads\" />
</ItemGroup>
</Project>

View File

@ -13,6 +13,7 @@ public class Program
{
endpointOptions.Protocols = HttpProtocols.Http2;
});
options.Limits.MaxRequestBodySize = null;
});
builder.Services.AddControllers();

View File

@ -7,17 +7,15 @@ namespace HTTP2FileStreams;
public class UploadController : ControllerBase
{
[HttpPost]
[DisableFormValueModelBinding] // Отключаем стандартный парсинг формы
[DisableFormValueModelBinding]
public async Task<IActionResult> 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");