feat: fixed upload
This commit is contained in:
parent
0d35453628
commit
40d91c8d84
@ -12,4 +12,8 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Uploads\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -13,6 +13,7 @@ public class Program
|
||||
{
|
||||
endpointOptions.Protocols = HttpProtocols.Http2;
|
||||
});
|
||||
options.Limits.MaxRequestBodySize = null;
|
||||
});
|
||||
builder.Services.AddControllers();
|
||||
|
||||
|
@ -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");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user