feat: fixed upload
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user