using CoviDok.BLL.Storage; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; using Minio; using Microsoft.Extensions.Options; namespace CoviDok.Data.StorageProviders { public class MinioProvider : IStorageProvider { private readonly MinioClient Client = null; public static MinioSettings _settings; public MinioProvider() { //var _settings = options.Value; Client = new MinioClient(_settings.HostName, _settings.AccessKey, _settings.SecretKey); } public async Task CreateNamespace(string ns) { await Client.MakeBucketAsync(ns); } public async Task Download(string ns, string objectname, Action callback) { await Client.GetObjectAsync(ns, objectname, callback); } public async Task NamespaceExists(string ns) { return await Client.BucketExistsAsync(ns); } public async Task Upload(string ns, string objectname, Stream data, long size) { await Client.PutObjectAsync(ns, objectname, data, size); } public async Task ObjectExists(string ns, string objectname) { try { await Client.StatObjectAsync(ns, objectname); return true; } catch (Exception) { return false; } } } }