This repository has been archived on 2023-06-30. You can view files and clone it, but cannot push or open issues or pull requests.
2chBackAPI/DBControllers/MinIOchat.cs
RakVhalate 32bb6d34e0
All checks were successful
continuous-integration/drone/push Build is passing
Thumbnail feature.
2022-12-07 19:55:18 +10:00

37 lines
1.4 KiB
C#

using Microsoft.AspNetCore.Mvc;
using Minio.DataModel;
using Minio;
using System.Security.Cryptography;
namespace NeDvachAPI.DBControllers
{
public class MinIOchat
{
public static async Task<JsonResult> PictureUpload(string fileroute, string filename, string bucket)
{
MinioClient DvachIo = new MinioClient()
.WithEndpoint(AuthInfo.MinIo.endpoint)
.WithCredentials(AuthInfo.MinIo.username, AuthInfo.MinIo.password)
//.WithSSL()
.Build();
Aes aesEncryption = Aes.Create();
aesEncryption.KeySize = 256;
aesEncryption.GenerateKey();
var ssec = new SSEC(aesEncryption.Key);
PutObjectArgs putObjectArgs = new PutObjectArgs()
.WithBucket(bucket)
.WithObject(filename)
.WithFileName(fileroute)
.WithContentType("image/png");
//.WithServerSideEncryption(ssec);
await DvachIo.PutObjectAsync(putObjectArgs);
GC.Collect();
GC.WaitForPendingFinalizers();
File.Delete(fileroute);
return new JsonResult("http://static.vdk2ch.ru:15555/thread-pics/" + filename);
}
}
}