using Minio; using Minio.Exceptions; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; namespace CoviDok.BLL { class MinioHandler { private readonly MinioClient Client = null; public MinioHandler(string Host, string AccessKey, string SecretKey) { //Client = new MinioClient( //"192.168.0.160:9000", //"secretaccesskey", //"secretsecretkey"); Client = new MinioClient(Host, AccessKey, SecretKey); } public async Task UploadImage(string BucketName, Stream FilePath, long size, string ObjectName) { try { // Make a bucket on the server, if not already present. bool found = await Client.BucketExistsAsync(BucketName); if (!found) { await Client.MakeBucketAsync(BucketName); } // Upload a file to bucket. await Client.PutObjectAsync(BucketName, ObjectName, FilePath, size); return new MinioResult(true, BucketName + ":" + ObjectName); } catch (MinioException e) { return new MinioResult(false, e.Message); } } public async Task GetImage(string ImageID, Action callback) { string[] attrs = ImageID.Split(":"); await Client.GetObjectAsync(attrs[0], attrs[1], callback); } } }