This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.VisualBasic;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using System.IO;
|
||||
|
||||
|
||||
@@ -18,18 +20,25 @@ namespace NeDvachAPI.Controllers
|
||||
var supportedTypes = new[] { "jpg", "png" };
|
||||
string receivedFileName = PostPicture.FileName;
|
||||
string fileExt = receivedFileName.Substring((receivedFileName.Length) - 3, 3);
|
||||
Console.WriteLine("Тип файла: " + fileExt);
|
||||
//Console.WriteLine("Тип файла: " + fileExt);
|
||||
if (supportedTypes.Contains(fileExt)) //file type check
|
||||
{
|
||||
|
||||
filePath = Directory.GetCurrentDirectory() + "\\Buffer\\" + receivedFileName;
|
||||
Stream picBuffer = new FileStream(filePath, FileMode.Create, FileAccess.Write);
|
||||
Console.WriteLine("Закидываю файл в " + filePath);
|
||||
Stream picBuffer = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
|
||||
//Console.WriteLine("Закидываю файл в " + filePath);
|
||||
PostPicture.CopyTo(picBuffer);
|
||||
picBuffer.Close();
|
||||
return new JsonResult(await MinIOchat.PictureUpload(filePath, receivedFileName));
|
||||
}
|
||||
///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("Неверный тип файла");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user