diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0f59e7..8bbd03d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,10 @@ jobs: - uses: actions/setup-dotnet@v2 with: dotnet-version: "6.0.x" - + + - name: Enable Homebrew + run: echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH + - name: Install License Finder tool with Homebrew uses: tecoli-com/actions-use-homebrew-tools@v0 with: diff --git a/doc/dependency_decisions.yml b/doc/dependency_decisions.yml index 81483bc..26c375d 100644 --- a/doc/dependency_decisions.yml +++ b/doc/dependency_decisions.yml @@ -4,21 +4,21 @@ - :who: mocsharp :why: Apache-2.0 (https://github.com/aws/aws-sdk-net/raw/master/License.txt) :versions: - - 3.7.13.8 + - 3.7.100.1 :when: 2022-08-29 18:11:12.923214877 Z - - :approve - AWSSDK.S3 - :who: mocsharp :why: Apache-2.0 (https://github.com/aws/aws-sdk-net/raw/master/License.txt) :versions: - - 3.7.9.57 + - 3.7.101.1 :when: 2022-08-29 18:11:13.354973002 Z - - :approve - AWSSDK.SecurityToken - :who: mocsharp :why: Apache-2.0 (https://github.com/aws/aws-sdk-net/raw/master/License.txt) :versions: - - 3.7.1.203 + - 3.7.100.1 :when: 2022-08-16 18:11:13.781079769 Z - - :approve - Ardalis.GuardClauses @@ -67,7 +67,7 @@ - :who: mocsharp :why: MIT (https://github.com/microsoft/vstest/raw/v17.3.0/LICENSE) :versions: - - 17.3.1 + - 17.3.2 :when: 2022-08-16 18:11:17.245887971 Z - - :approve - Microsoft.Extensions.Configuration @@ -144,14 +144,14 @@ - :who: mocsharp :why: MIT (https://github.com/dotnet/aspnetcore/raw/main/LICENSE.txt) :versions: - - 6.0.9 + - 6.0.10 :when: 2022-08-29 18:11:22.090772006 Z - - :approve - Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions - :who: mocsharp :why: MIT (https://github.com/dotnet/aspnetcore/raw/main/LICENSE.txt) :versions: - - 6.0.9 + - 6.0.10 :when: 2022-08-29 18:11:22.090772006 Z - - :approve - Microsoft.Extensions.FileProviders.Abstractions @@ -263,7 +263,7 @@ - :who: mocsharp :why: MIT (https://github.com/microsoft/vstest/raw/v17.3.0/LICENSE) :versions: - - 17.3.1 + - 17.3.2 :when: 2022-08-16 18:11:29.155295778 Z - - :approve - Microsoft.NETCore.Platforms @@ -298,14 +298,14 @@ - :who: mocsharp :why: MIT (https://github.com/microsoft/vstest/raw/v17.3.0/LICENSE) :versions: - - 17.3.1 + - 17.3.2 :when: 2022-08-16 18:11:32.293966383 Z - - :approve - Microsoft.TestPlatform.TestHost - :who: mocsharp :why: MIT (https://github.com/microsoft/vstest/raw/v17.3.0/LICENSE) :versions: - - 17.3.1 + - 17.3.2 :when: 2022-08-16 18:11:33.162650175 Z - - :approve - Microsoft.Win32.Primitives diff --git a/src/Plugins/AWSS3/Monai.Deploy.Storage.AWSS3.csproj b/src/Plugins/AWSS3/Monai.Deploy.Storage.AWSS3.csproj index 8a7cc47..d86d456 100644 --- a/src/Plugins/AWSS3/Monai.Deploy.Storage.AWSS3.csproj +++ b/src/Plugins/AWSS3/Monai.Deploy.Storage.AWSS3.csproj @@ -49,8 +49,8 @@ - - + + diff --git a/src/Plugins/MinIO/ConfigurationKeys.cs b/src/Plugins/MinIO/ConfigurationKeys.cs index 16887af..150ae19 100644 --- a/src/Plugins/MinIO/ConfigurationKeys.cs +++ b/src/Plugins/MinIO/ConfigurationKeys.cs @@ -28,6 +28,7 @@ internal static class ConfigurationKeys public static readonly string CredentialServiceUrl = "credentialServiceUrl"; public static readonly string McExecutablePath = "executableLocation"; public static readonly string McServiceName = "serviceName"; + public static readonly string CreateBuckets = "createBuckets"; public static readonly string[] RequiredKeys = new[] { EndPoint, AccessKey, AccessToken, SecuredConnection, Region }; public static readonly string[] McRequiredKeys = new[] { EndPoint, AccessKey, AccessToken, McExecutablePath, McServiceName }; diff --git a/src/Plugins/MinIO/IMinIoClientFactory.cs b/src/Plugins/MinIO/IMinIoClientFactory.cs index c871f76..45da228 100644 --- a/src/Plugins/MinIO/IMinIoClientFactory.cs +++ b/src/Plugins/MinIO/IMinIoClientFactory.cs @@ -21,10 +21,22 @@ namespace Monai.Deploy.Storage.MinIO { public interface IMinIoClientFactory { - MinioClient GetClient(); + IMinioClient GetClient(); - MinioClient GetClient(Credentials credentials); + IMinioClient GetClient(Credentials credentials); - MinioClient GetClient(Credentials credentials, string region); + IMinioClient GetClient(Credentials credentials, string region); + + IObjectOperations GetObjectOperationsClient(); + + IObjectOperations GetObjectOperationsClient(Credentials credentials); + + IObjectOperations GetObjectOperationsClient(Credentials credentials, string region); + + IBucketOperations GetBucketOperationsClient(); + + IBucketOperations GetBucketOperationsClient(Credentials credentials); + + IBucketOperations GetBucketOperationsClient(Credentials credentials, string region); } } diff --git a/src/Plugins/MinIO/LoggerMethods.cs b/src/Plugins/MinIO/LoggerMethods.cs index 1c41d09..edf31ff 100644 --- a/src/Plugins/MinIO/LoggerMethods.cs +++ b/src/Plugins/MinIO/LoggerMethods.cs @@ -34,5 +34,14 @@ public static partial class LoggerMethods [LoggerMessage(EventId = 20004, Level = LogLevel.Debug, Message = "Temporary credential policy={policy}.")] public static partial void TemporaryCredentialPolicy(this ILogger logger, string policy); + + [LoggerMessage(EventId = 20005, Level = LogLevel.Information, Message = "`createBuckets` not configured; no buckets created.")] + public static partial void NoBucketCreated(this ILogger logger); + + [LoggerMessage(EventId = 20006, Level = LogLevel.Critical, Message = "Error creating bucket {bucket} in region {region}.")] + public static partial void ErrorCreatingBucket(this ILogger logger, string bucket, string region, Exception ex); + + [LoggerMessage(EventId = 20007, Level = LogLevel.Information, Message = "Bucket {bucket} created in region {region}.")] + public static partial void BucketCreated(this ILogger logger, string bucket, string region); } } diff --git a/src/Plugins/MinIO/MinIoClientFactory.cs b/src/Plugins/MinIO/MinIoClientFactory.cs index 9590efe..e0d72f4 100644 --- a/src/Plugins/MinIO/MinIoClientFactory.cs +++ b/src/Plugins/MinIO/MinIoClientFactory.cs @@ -42,47 +42,73 @@ public MinIoClientFactory(IOptions options) _clients = new ConcurrentDictionary(); } - public MinioClient GetClient() + public IMinioClient GetClient() { return _clients.GetOrAdd(DefaultClient, _ => - { - var accessKey = Options.Settings[ConfigurationKeys.AccessKey]; - var accessToken = Options.Settings[ConfigurationKeys.AccessToken]; - var client = CreateClient(accessKey, accessToken); + { + var accessKey = Options.Settings[ConfigurationKeys.AccessKey]; + var accessToken = Options.Settings[ConfigurationKeys.AccessToken]; + var client = CreateClient(accessKey, accessToken); - return client.Build(); - }); + return client.Build(); + }); } - public MinioClient GetClient(Credentials credentials) + public IMinioClient GetClient(Credentials credentials) { return GetClient(credentials, string.Empty); } - public MinioClient GetClient(Credentials credentials, string region) + public IMinioClient GetClient(Credentials credentials, string region) { - Guard.Against.Null(credentials, nameof(credentials)); - Guard.Against.NullOrWhiteSpace(credentials.AccessKeyId, nameof(credentials.AccessKeyId)); - Guard.Against.NullOrWhiteSpace(credentials.SecretAccessKey, nameof(credentials.SecretAccessKey)); - Guard.Against.NullOrWhiteSpace(credentials.SessionToken, nameof(credentials.SessionToken)); + return GetClientInternal(credentials, region); + } - return _clients.GetOrAdd(credentials.SessionToken, _ => + public IBucketOperations GetBucketOperationsClient() + { + return _clients.GetOrAdd(DefaultClient, _ => { - var client = CreateClient(credentials.AccessKeyId, credentials.SecretAccessKey); - client.WithSessionToken(credentials.SessionToken); - - if (!string.IsNullOrWhiteSpace(region)) - { - client.WithRegion(region); - } + var accessKey = Options.Settings[ConfigurationKeys.AccessKey]; + var accessToken = Options.Settings[ConfigurationKeys.AccessToken]; + var client = CreateClient(accessKey, accessToken); return client.Build(); }); + } + public IBucketOperations GetBucketOperationsClient(Credentials credentials) + { + return GetClientInternal(credentials, string.Empty); + } + public IBucketOperations GetBucketOperationsClient(Credentials credentials, string region) + { + return GetClientInternal(credentials, region); } - private MinioClient CreateClient(string accessKey, string accessToken) + public IObjectOperations GetObjectOperationsClient() + { + return _clients.GetOrAdd(DefaultClient, _ => + { + var accessKey = Options.Settings[ConfigurationKeys.AccessKey]; + var accessToken = Options.Settings[ConfigurationKeys.AccessToken]; + var client = CreateClient(accessKey, accessToken); + + return client.Build(); + }); + } + + public IObjectOperations GetObjectOperationsClient(Credentials credentials) + { + return GetClientInternal(credentials, string.Empty); + } + + public IObjectOperations GetObjectOperationsClient(Credentials credentials, string region) + { + return GetClientInternal(credentials, region); + } + + private IMinioClient CreateClient(string accessKey, string accessToken) { var endpoint = Options.Settings[ConfigurationKeys.EndPoint]; var securedConnection = Options.Settings[ConfigurationKeys.SecuredConnection]; @@ -99,6 +125,27 @@ private MinioClient CreateClient(string accessKey, string accessToken) return client; } + private MinioClient GetClientInternal(Credentials credentials, string region) + { + Guard.Against.Null(credentials, nameof(credentials)); + Guard.Against.NullOrWhiteSpace(credentials.AccessKeyId, nameof(credentials.AccessKeyId)); + Guard.Against.NullOrWhiteSpace(credentials.SecretAccessKey, nameof(credentials.SecretAccessKey)); + Guard.Against.NullOrWhiteSpace(credentials.SessionToken, nameof(credentials.SessionToken)); + + return _clients.GetOrAdd(credentials.SessionToken, _ => + { + var client = CreateClient(credentials.AccessKeyId, credentials.SecretAccessKey); + client.WithSessionToken(credentials.SessionToken); + + if (!string.IsNullOrWhiteSpace(region)) + { + client.WithRegion(region); + } + + return client.Build(); + }); + } + private void ValidateConfiguration(StorageServiceConfiguration configuration) { Guard.Against.Null(configuration, nameof(configuration)); diff --git a/src/Plugins/MinIO/MinIoHealthCheck.cs b/src/Plugins/MinIO/MinIoHealthCheck.cs index f070bb1..d52f496 100644 --- a/src/Plugins/MinIO/MinIoHealthCheck.cs +++ b/src/Plugins/MinIO/MinIoHealthCheck.cs @@ -34,7 +34,7 @@ public MinIoHealthCheck(IMinIoClientFactory minIoClientFactory, ILogger _options; + private readonly ILogger _logger; + + public MinIoStartup( + IMinIoClientFactory minIoClientFactory, + IOptions options, + ILogger logger) + { + _minIoClientFactory = minIoClientFactory ?? throw new ArgumentNullException(nameof(minIoClientFactory)); + _options = options ?? throw new ArgumentNullException(nameof(options)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + } + + public async Task StartAsync(CancellationToken cancellationToken) + { + if (_options.Value.Settings.ContainsKey(ConfigurationKeys.CreateBuckets)) + { + var buckets = _options.Value.Settings[ConfigurationKeys.CreateBuckets]; + var region = _options.Value.Settings.ContainsKey(ConfigurationKeys.Region) ? _options.Value.Settings[ConfigurationKeys.Region] : string.Empty; + + if (!string.IsNullOrWhiteSpace(buckets)) + { + var exceptions = new List(); + var bucketNames = buckets.Split(',', StringSplitOptions.RemoveEmptyEntries); + + var client = _minIoClientFactory.GetBucketOperationsClient(); + + foreach (var bucket in bucketNames) + { + try + { + await CreateBucket(client, bucket.Trim(), region, cancellationToken).ConfigureAwait(false); + } + catch (Exception ex) + { + _logger.ErrorCreatingBucket(bucket, region, ex); + exceptions.Add(ex); + } + } + + if (exceptions.Any()) + { + throw new AggregateException("Error creating buckets.", exceptions); + } + } + } + else + { + _logger.NoBucketCreated(); + } + } + + public Task StopAsync(CancellationToken cancellationToken) + { + return Task.CompletedTask; + } + + private async Task CreateBucket(IBucketOperations client, string bucket, string region, CancellationToken cancellationToken) + { + Guard.Against.Null(client, nameof(client)); + Guard.Against.Null(bucket, nameof(bucket)); + + var bucketExistsArgs = new BucketExistsArgs().WithBucket(bucket); + if (!await client.BucketExistsAsync(bucketExistsArgs, cancellationToken).ConfigureAwait(false)) + { + var makeBucketArgs = new MakeBucketArgs().WithBucket(bucket); + if (!string.IsNullOrWhiteSpace(region)) + { + makeBucketArgs.WithLocation(region); + } + await client.MakeBucketAsync(makeBucketArgs, cancellationToken).ConfigureAwait(false); + _logger.BucketCreated(bucket, region); + } + } + } +} diff --git a/src/Plugins/MinIO/MinIoStorageService.cs b/src/Plugins/MinIO/MinIoStorageService.cs index aab5217..1b4adb5 100644 --- a/src/Plugins/MinIO/MinIoStorageService.cs +++ b/src/Plugins/MinIO/MinIoStorageService.cs @@ -39,7 +39,7 @@ public class MinIoStorageService : IStorageService public MinIoStorageService(IMinIoClientFactory minioClientFactory, IAmazonSecurityTokenServiceClientFactory amazonSecurityTokenServiceClientFactory, IOptions options, ILogger logger) { Guard.Against.Null(options, nameof(options)); - _minioClientFactory = minioClientFactory ?? throw new ArgumentNullException(nameof(minioClientFactory)); + _minioClientFactory = minioClientFactory ?? throw new ArgumentNullException(nameof(IMinIoClientFactory)); _amazonSecurityTokenServiceClientFactory = amazonSecurityTokenServiceClientFactory ?? throw new ArgumentNullException(nameof(amazonSecurityTokenServiceClientFactory)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); @@ -71,7 +71,7 @@ public async Task CopyObjectAsync(string sourceBucketName, string sourceObjectNa Guard.Against.NullOrWhiteSpace(destinationBucketName, nameof(destinationBucketName)); Guard.Against.NullOrWhiteSpace(destinationObjectName, nameof(destinationObjectName)); - var client = _minioClientFactory.GetClient(); + var client = _minioClientFactory.GetObjectOperationsClient(); await CopyObjectUsingClient(client, sourceBucketName, sourceObjectName, destinationBucketName, destinationObjectName, cancellationToken).ConfigureAwait(false); } @@ -80,7 +80,7 @@ public async Task GetObjectAsync(string bucketName, string objectName, C Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); Guard.Against.NullOrWhiteSpace(objectName, nameof(objectName)); - var client = _minioClientFactory.GetClient(); + var client = _minioClientFactory.GetObjectOperationsClient(); var stream = new MemoryStream(); await GetObjectUsingClient(client, bucketName, objectName, (s) => s.CopyTo(stream), cancellationToken).ConfigureAwait(false); stream.Seek(0, SeekOrigin.Begin); @@ -91,7 +91,7 @@ public async Task> ListObjectsAsync(string bucketName, st { Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); - var client = _minioClientFactory.GetClient(); + var client = _minioClientFactory.GetBucketOperationsClient(); return await ListObjectsUsingClient(client, bucketName, prefix, recursive, cancellationToken).ConfigureAwait(false); } @@ -154,7 +154,7 @@ public async Task PutObjectAsync(string bucketName, string objectName, Stream da Guard.Against.Null(data, nameof(data)); Guard.Against.NullOrWhiteSpace(contentType, nameof(contentType)); - var client = _minioClientFactory.GetClient(); + var client = _minioClientFactory.GetObjectOperationsClient(); await PutObjectUsingClient(client, bucketName, objectName, data, size, contentType, metadata, cancellationToken).ConfigureAwait(false); } @@ -163,7 +163,7 @@ public async Task RemoveObjectAsync(string bucketName, string objectName, Cancel Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); Guard.Against.NullOrWhiteSpace(objectName, nameof(objectName)); - var client = _minioClientFactory.GetClient(); + var client = _minioClientFactory.GetObjectOperationsClient(); await RemoveObjectUsingClient(client, bucketName, objectName, cancellationToken).ConfigureAwait(false); } @@ -172,7 +172,7 @@ public async Task RemoveObjectsAsync(string bucketName, IEnumerable obje Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); Guard.Against.NullOrEmpty(objectNames, nameof(objectNames)); - var client = _minioClientFactory.GetClient(); + var client = _minioClientFactory.GetObjectOperationsClient(); await RemoveObjectsUsingClient(client, bucketName, objectNames, cancellationToken).ConfigureAwait(false); } @@ -223,7 +223,7 @@ public async Task CopyObjectWithCredentialsAsync(string sourceBucketName, string Guard.Against.NullOrWhiteSpace(destinationBucketName, nameof(destinationBucketName)); Guard.Against.NullOrWhiteSpace(destinationObjectName, nameof(destinationObjectName)); - var client = _minioClientFactory.GetClient(credentials, _options.Settings[ConfigurationKeys.Region]); + var client = _minioClientFactory.GetObjectOperationsClient(credentials, _options.Settings[ConfigurationKeys.Region]); await CopyObjectUsingClient(client, sourceBucketName, sourceObjectName, destinationBucketName, destinationObjectName, cancellationToken).ConfigureAwait(false); } @@ -232,7 +232,7 @@ public async Task GetObjectWithCredentialsAsync(string bucketName, strin Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); Guard.Against.NullOrWhiteSpace(objectName, nameof(objectName)); - var client = _minioClientFactory.GetClient(credentials, _options.Settings[ConfigurationKeys.Region]); + var client = _minioClientFactory.GetObjectOperationsClient(credentials, _options.Settings[ConfigurationKeys.Region]); var stream = new MemoryStream(); await GetObjectUsingClient(client, bucketName, objectName, (s) => s.CopyTo(stream), cancellationToken).ConfigureAwait(false); stream.Seek(0, SeekOrigin.Begin); @@ -243,7 +243,7 @@ public async Task> ListObjectsWithCredentialsAsync(string { Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); - var client = _minioClientFactory.GetClient(credentials, _options.Settings[ConfigurationKeys.Region]); + var client = _minioClientFactory.GetBucketOperationsClient(credentials, _options.Settings[ConfigurationKeys.Region]); return await ListObjectsUsingClient(client, bucketName, prefix, recursive, cancellationToken).ConfigureAwait(false); } @@ -254,7 +254,7 @@ public async Task PutObjectWithCredentialsAsync(string bucketName, string object Guard.Against.Null(data, nameof(data)); Guard.Against.NullOrWhiteSpace(contentType, nameof(contentType)); - var client = _minioClientFactory.GetClient(credentials, _options.Settings[ConfigurationKeys.Region]); + var client = _minioClientFactory.GetObjectOperationsClient(credentials, _options.Settings[ConfigurationKeys.Region]); await PutObjectUsingClient(client, bucketName, objectName, data, size, contentType, metadata, cancellationToken).ConfigureAwait(false); } @@ -263,7 +263,7 @@ public async Task RemoveObjectWithCredentialsAsync(string bucketName, string obj Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); Guard.Against.NullOrWhiteSpace(objectName, nameof(objectName)); - var client = _minioClientFactory.GetClient(credentials, _options.Settings[ConfigurationKeys.Region]); + var client = _minioClientFactory.GetObjectOperationsClient(credentials, _options.Settings[ConfigurationKeys.Region]); await RemoveObjectUsingClient(client, bucketName, objectName, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -272,7 +272,7 @@ public async Task RemoveObjectsWithCredentialsAsync(string bucketName, IEnumerab Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); Guard.Against.NullOrEmpty(objectNames, nameof(objectNames)); - var client = _minioClientFactory.GetClient(credentials, _options.Settings[ConfigurationKeys.Region]); + var client = _minioClientFactory.GetObjectOperationsClient(credentials, _options.Settings[ConfigurationKeys.Region]); await RemoveObjectsUsingClient(client, bucketName, objectNames, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -287,7 +287,7 @@ public async Task CreateFolderWithCredentialsAsync(string bucketName, string fol var length = data.Length; var stream = new MemoryStream(data); - var client = _minioClientFactory.GetClient(credentials, _options.Settings[ConfigurationKeys.Region]); + var client = _minioClientFactory.GetObjectOperationsClient(credentials, _options.Settings[ConfigurationKeys.Region]); await PutObjectUsingClient(client, bucketName, stubFile, stream, length, "application/octet-stream", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -295,7 +295,7 @@ public async Task CreateFolderWithCredentialsAsync(string bucketName, string fol #region Internal Helper Methods - private static async Task CopyObjectUsingClient(MinioClient client, string sourceBucketName, string sourceObjectName, string destinationBucketName, string destinationObjectName, CancellationToken cancellationToken) + private static async Task CopyObjectUsingClient(IObjectOperations client, string sourceBucketName, string sourceObjectName, string destinationBucketName, string destinationObjectName, CancellationToken cancellationToken) { var copySourceObjectArgs = new CopySourceObjectArgs() .WithBucket(sourceBucketName) @@ -307,7 +307,7 @@ private static async Task CopyObjectUsingClient(MinioClient client, string sourc await client.CopyObjectAsync(copyObjectArgs, cancellationToken).ConfigureAwait(false); } - private static async Task GetObjectUsingClient(MinioClient client, string bucketName, string objectName, Action callback, CancellationToken cancellationToken) + private static async Task GetObjectUsingClient(IObjectOperations client, string bucketName, string objectName, Action callback, CancellationToken cancellationToken) { var args = new GetObjectArgs() .WithBucket(bucketName) @@ -316,7 +316,7 @@ private static async Task GetObjectUsingClient(MinioClient client, string bucket await client.GetObjectAsync(args, cancellationToken).ConfigureAwait(false); } - private async Task> ListObjectsUsingClient(MinioClient client, string bucketName, string? prefix, bool recursive, CancellationToken cancellationToken) + private async Task> ListObjectsUsingClient(IBucketOperations client, string bucketName, string? prefix, bool recursive, CancellationToken cancellationToken) { return await Task.Run(() => { @@ -349,7 +349,7 @@ private async Task> ListObjectsUsingClient(MinioClient cl }).ConfigureAwait(false); } - private static async Task RemoveObjectUsingClient(MinioClient client, string bucketName, string objectName, CancellationToken cancellationToken) + private static async Task RemoveObjectUsingClient(IObjectOperations client, string bucketName, string objectName, CancellationToken cancellationToken) { var args = new RemoveObjectArgs() .WithBucket(bucketName) @@ -357,7 +357,7 @@ private static async Task RemoveObjectUsingClient(MinioClient client, string buc await client.RemoveObjectAsync(args, cancellationToken).ConfigureAwait(false); } - private static async Task PutObjectUsingClient(MinioClient client, string bucketName, string objectName, Stream data, long size, string contentType, Dictionary? metadata, CancellationToken cancellationToken) + private static async Task PutObjectUsingClient(IObjectOperations client, string bucketName, string objectName, Stream data, long size, string contentType, Dictionary? metadata, CancellationToken cancellationToken) { var args = new PutObjectArgs() .WithBucket(bucketName) @@ -373,7 +373,7 @@ private static async Task PutObjectUsingClient(MinioClient client, string bucket await client.PutObjectAsync(args, cancellationToken).ConfigureAwait(false); } - private static async Task RemoveObjectsUsingClient(MinioClient client, string bucketName, IEnumerable objectNames, CancellationToken cancellationToken) + private static async Task RemoveObjectsUsingClient(IObjectOperations client, string bucketName, IEnumerable objectNames, CancellationToken cancellationToken) { var args = new RemoveObjectsArgs() .WithBucket(bucketName) diff --git a/src/Plugins/MinIO/Monai.Deploy.Storage.MinIO.csproj b/src/Plugins/MinIO/Monai.Deploy.Storage.MinIO.csproj index 12e6c5f..12b0a62 100644 --- a/src/Plugins/MinIO/Monai.Deploy.Storage.MinIO.csproj +++ b/src/Plugins/MinIO/Monai.Deploy.Storage.MinIO.csproj @@ -1,4 +1,4 @@ -