feat: fixed upload
This commit is contained in:
parent
0d35453628
commit
40d91c8d84
@ -12,4 +12,8 @@
|
|||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Uploads\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -13,6 +13,7 @@ public class Program
|
|||||||
{
|
{
|
||||||
endpointOptions.Protocols = HttpProtocols.Http2;
|
endpointOptions.Protocols = HttpProtocols.Http2;
|
||||||
});
|
});
|
||||||
|
options.Limits.MaxRequestBodySize = null;
|
||||||
});
|
});
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
|
|
||||||
|
@ -7,17 +7,15 @@ namespace HTTP2FileStreams;
|
|||||||
public class UploadController : ControllerBase
|
public class UploadController : ControllerBase
|
||||||
{
|
{
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[DisableFormValueModelBinding] // Отключаем стандартный парсинг формы
|
[DisableFormValueModelBinding]
|
||||||
public async Task<IActionResult> Upload()
|
public async Task<IActionResult> Upload()
|
||||||
{
|
{
|
||||||
// Получаем имя файла из заголовка
|
|
||||||
var fileName = Request.Headers["X-File-Name"].ToString();
|
var fileName = Request.Headers["X-File-Name"].ToString();
|
||||||
if (string.IsNullOrEmpty(fileName))
|
if (string.IsNullOrEmpty(fileName))
|
||||||
return BadRequest("File name header is missing");
|
return BadRequest("File name header is missing");
|
||||||
|
|
||||||
fileName = Uri.UnescapeDataString(fileName);
|
fileName = Uri.UnescapeDataString(fileName);
|
||||||
|
|
||||||
// Потоковая запись файла
|
|
||||||
if (!Directory.Exists("Uploads"))
|
if (!Directory.Exists("Uploads"))
|
||||||
Directory.CreateDirectory("Uploads");
|
Directory.CreateDirectory("Uploads");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user