36 lines
1.4 KiB
C#
36 lines
1.4 KiB
C#
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
using Minio.DataModel;
|
|||
|
using Minio;
|
|||
|
using System.Security.Cryptography;
|
|||
|
|
|||
|
namespace NeDvachAPI
|
|||
|
{
|
|||
|
public class MinIOchat
|
|||
|
{
|
|||
|
public static async Task<string> PictureUpload(string fileroute, string filename)
|
|||
|
{
|
|||
|
MinioClient DvachIo = new MinioClient()
|
|||
|
.WithEndpoint(AuthInfo.MinIo.endpoint)
|
|||
|
.WithCredentials(AuthInfo.MinIo.username, AuthInfo.MinIo.password)
|
|||
|
//.WithSSL()
|
|||
|
.Build();
|
|||
|
Console.WriteLine(filename);
|
|||
|
|
|||
|
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);
|
|||
|
Console.WriteLine("Кидаю в minio...");
|
|||
|
await DvachIo.PutObjectAsync(putObjectArgs);
|
|||
|
|
|||
|
return "http://static.vdk2ch.ru:15555/thread-pics/" + filename;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|