|
|
|
@ -37,7 +37,11 @@ public class MinioBlobProvider : BlobProviderBase, ITransientDependency |
|
|
|
await CreateBucketIfNotExists(client, containerName); |
|
|
|
} |
|
|
|
|
|
|
|
await client.PutObjectAsync(containerName, blobName, args.BlobStream, args.BlobStream.Length); |
|
|
|
await client.PutObjectAsync(new PutObjectArgs() |
|
|
|
.WithBucket(containerName) |
|
|
|
.WithObject(blobName) |
|
|
|
.WithStreamData(args.BlobStream) |
|
|
|
.WithObjectSize(args.BlobStream.Length)); |
|
|
|
} |
|
|
|
|
|
|
|
public override async Task<bool> DeleteAsync(BlobProviderDeleteArgs args) |
|
|
|
@ -46,13 +50,14 @@ public class MinioBlobProvider : BlobProviderBase, ITransientDependency |
|
|
|
var client = GetMinioClient(args); |
|
|
|
var containerName = GetContainerName(args); |
|
|
|
|
|
|
|
if (await BlobExistsAsync(client, containerName, blobName)) |
|
|
|
if (!await BlobExistsAsync(client, containerName, blobName)) |
|
|
|
{ |
|
|
|
await client.RemoveObjectAsync(containerName, blobName); |
|
|
|
return true; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
await client.RemoveObjectAsync(new RemoveObjectArgs().WithBucket(containerName).WithObject(blobName)); |
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public override async Task<bool> ExistsAsync(BlobProviderExistsArgs args) |
|
|
|
@ -76,7 +81,7 @@ public class MinioBlobProvider : BlobProviderBase, ITransientDependency |
|
|
|
} |
|
|
|
|
|
|
|
var memoryStream = new MemoryStream(); |
|
|
|
await client.GetObjectAsync(containerName, blobName, (stream) => |
|
|
|
await client.GetObjectAsync(new GetObjectArgs().WithBucket(containerName).WithObject(blobName).WithCallbackStream(stream => |
|
|
|
{ |
|
|
|
if (stream != null) |
|
|
|
{ |
|
|
|
@ -87,7 +92,7 @@ public class MinioBlobProvider : BlobProviderBase, ITransientDependency |
|
|
|
{ |
|
|
|
memoryStream = null; |
|
|
|
} |
|
|
|
}); |
|
|
|
})); |
|
|
|
|
|
|
|
return memoryStream; |
|
|
|
} |
|
|
|
@ -110,20 +115,20 @@ public class MinioBlobProvider : BlobProviderBase, ITransientDependency |
|
|
|
|
|
|
|
protected virtual async Task CreateBucketIfNotExists(MinioClient client, string containerName) |
|
|
|
{ |
|
|
|
if (!await client.BucketExistsAsync(containerName)) |
|
|
|
if (!await client.BucketExistsAsync(new BucketExistsArgs().WithBucket(containerName))) |
|
|
|
{ |
|
|
|
await client.MakeBucketAsync(containerName); |
|
|
|
await client.MakeBucketAsync(new MakeBucketArgs().WithBucket(containerName)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual async Task<bool> BlobExistsAsync(MinioClient client, string containerName, string blobName) |
|
|
|
{ |
|
|
|
// Make sure Blob Container exists.
|
|
|
|
if (await client.BucketExistsAsync(containerName)) |
|
|
|
if (await client.BucketExistsAsync(new BucketExistsArgs().WithBucket(containerName))) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
await client.StatObjectAsync(containerName, blobName); |
|
|
|
await client.StatObjectAsync(new StatObjectArgs().WithBucket(containerName).WithObject(blobName)); |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
|