
2 changed files with 76 additions and 73 deletions
@ -1,56 +1,59 @@ |
|||||
using CoviDok.BLL.Storage; |
using CoviDok.BLL.Storage; |
||||
using System; |
using System; |
||||
using System.Collections.Generic; |
using System.Collections.Generic; |
||||
using System.IO; |
using System.IO; |
||||
using System.Linq; |
using System.Linq; |
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
using Minio; |
using Minio; |
||||
using Microsoft.Extensions.Options; |
using Microsoft.Extensions.Options; |
||||
|
|
||||
namespace CoviDok.Data.StorageProviders |
namespace CoviDok.Data.StorageProviders |
||||
{ |
{ |
||||
public class MinioProvider : IStorageProvider |
public class MinioProvider : IStorageProvider |
||||
{ |
{ |
||||
private readonly MinioClient Client = null; |
private readonly MinioClient Client = null; |
||||
|
|
||||
public static MinioSettings _settings; |
public static MinioSettings _settings; |
||||
public MinioProvider() |
public MinioProvider() |
||||
{ |
{ |
||||
//var _settings = options.Value;
|
//var _settings = options.Value;
|
||||
Client = new MinioClient(_settings.HostName, _settings.AccessKey, _settings.SecretKey); |
Client = new MinioClient(_settings.HostName, _settings.AccessKey, _settings.SecretKey); |
||||
} |
} |
||||
|
|
||||
public async Task CreateNamespace(string ns) |
public async Task CreateNamespace(string ns) |
||||
{ |
{ |
||||
await Client.MakeBucketAsync(ns); |
await Client.MakeBucketAsync(ns); |
||||
} |
} |
||||
|
|
||||
public async Task Download(string ns, string objectname, Action<Stream> callback) |
public async Task Download(string ns, string objectname, Action<Stream> callback) |
||||
{ |
{ |
||||
await Client.GetObjectAsync(ns, objectname, callback); |
await Client.GetObjectAsync(ns, objectname, callback); |
||||
} |
} |
||||
|
|
||||
public async Task<bool> NamespaceExists(string ns) |
public async Task<bool> NamespaceExists(string ns) |
||||
{ |
{ |
||||
return await Client.BucketExistsAsync(ns); |
Console.WriteLine("MinioProvider:NamespaceExists - Checking " + ns); |
||||
} |
bool exists = await Client.BucketExistsAsync(ns); |
||||
|
Console.WriteLine("MinioProvider:NamespaceExists - " + ns + " exists" ); |
||||
public async Task Upload(string ns, string objectname, Stream data, long size) |
return exists; |
||||
{ |
} |
||||
await Client.PutObjectAsync(ns, objectname, data, size); |
|
||||
} |
public async Task Upload(string ns, string objectname, Stream data, long size) |
||||
|
{ |
||||
public async Task<bool> ObjectExists(string ns, string objectname) |
await Client.PutObjectAsync(ns, objectname, data, size); |
||||
{ |
} |
||||
try { |
|
||||
await Client.StatObjectAsync(ns, objectname); |
public async Task<bool> ObjectExists(string ns, string objectname) |
||||
return true; |
{ |
||||
} |
try { |
||||
catch (Exception) |
await Client.StatObjectAsync(ns, objectname); |
||||
{ |
return true; |
||||
return false; |
} |
||||
} |
catch (Exception) |
||||
|
{ |
||||
} |
return false; |
||||
} |
} |
||||
} |
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
@ -1,17 +1,17 @@ |
|||||
apiVersion: v1 |
apiVersion: v1 |
||||
kind: ConfigMap |
kind: ConfigMap |
||||
metadata: |
metadata: |
||||
name: {{ include "covidok.appsettings" . }} |
name: {{ include "covidok.appsettings" . }} |
||||
data: |
data: |
||||
appsettings.k8s.json: | |
appsettings.k8s.json: | |
||||
{ |
{ |
||||
"ConnectionStrings": { |
"ConnectionStrings": { |
||||
"MySQLDatabase": "server={{- include "covidok.mysql" . -}};database={{ .Values.config.mysql.database }};user={{ .Values.config.mysql.user }};password={{ .Values.config.mysql.password }}", |
"MySQLDatabase": "server={{- include "covidok.mysql" . -}};database={{ .Values.config.mysql.database }};user={{ .Values.config.mysql.user }};password={{ .Values.config.mysql.password }}", |
||||
"RedisHost": "{{ include "covidok.redis" . }}:{{ .Values.config.redis.port }}" |
"RedisHost": "{{ include "covidok.redis" . }}:{{ .Values.config.redis.port }}" |
||||
}, |
}, |
||||
"MinioSettings": { |
"MinioSettings": { |
||||
"HostName": "{{ include "covidok.minio" . }}", |
"HostName": "{{ include "covidok.minio" . }}:9000", |
||||
"AccessKey": "{{ .Values.config.minio.accesskey }}", |
"AccessKey": "{{ .Values.config.minio.accesskey }}", |
||||
"SecretKey": "{{ .Values.config.minio.secretkey }}" |
"SecretKey": "{{ .Values.config.minio.secretkey }}" |
||||
} |
} |
||||
} |
} |
||||
|
Loading…
Reference in new issue