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/MinIOchat.cs
RakVhalate 50a3c94af8
All checks were successful
continuous-integration/drone/push Build is passing
added buffer and some error handling
2022-11-25 12:37:26 +10:00

37 lines
1.5 KiB
C#

using Microsoft.AspNetCore.Mvc;
using Minio.DataModel;
using Minio;
using System.Security.Cryptography;
namespace NeDvachAPI
{
public class MinIOchat
{
public static async Task<JsonResult> PictureUpload(string fileroute, string filename)
{
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(AuthInfo.MinIo.bucketName)
.WithObject(filename)
.WithFileName(fileroute)
.WithContentType("image/png");
//.WithServerSideEncryption(ssec);
await DvachIo.PutObjectAsync(putObjectArgs);
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
File.Delete(fileroute);
return new JsonResult("http://static.vdk2ch.ru:15555/thread-pics/" + filename);
}
}
}