using Microsoft.AspNetCore.Mvc; using NeDvachAPI.DBControllers; namespace NeDvachAPI.Controllers { [ApiController] [Route("[controller]")] public class UploadPic : ControllerBase { [HttpPost(Name = "UploadPicture")] public async Task ReceivePost([FromForm] IFormFile PostPicture) { var supportedTypes = new[] { "jpg", "png" }; string receivedFileName = PostPicture.FileName; string fileExt = receivedFileName.Substring((receivedFileName.Length) - 3, 3); if (supportedTypes.Contains(fileExt.ToLower())) //file type check { ///Local Buffer File Part string filePath; filePath = Directory.GetCurrentDirectory() + "\\Buffer\\" + receivedFileName; Stream picBuffer = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); PostPicture.CopyTo(picBuffer); picBuffer.Close(); ///MinIo part JsonResult picAdress = new(await MinIOchat.PictureUpload(filePath, receivedFileName)); Console.WriteLine("Загружен файл:" + "http://static.vdk2ch.ru:15555/thread-pics/" + receivedFileName); return picAdress; } else return new JsonResult("Неверный тип файла"); } } }