-
Notifications
You must be signed in to change notification settings - Fork 260
Closed
Description
This issue follows on from my previous issue #673 , its the same code but a different path through to the issue
I am using the following code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Minio;
namespace MinioClientTest
{
class Program
{
static async Task Main()
{
var minIoClient = new MinioClient().WithEndpoint("localhost:9000").WithCredentials("LocalaccessKey", "localSecretKey").Build();
var amazonClient = new MinioClient().WithEndpoint("s3.amazonaws.com").WithCredentials("s3AccessKey", "s3AccessSecret").WithSSL().WithRegion("eu-west-2").Build();
var minIoSourceBucket = "default";
var minIoSourceFilePath = "SomeLogFile.txt";
var amazonSinkBucket = "SomeBucket";
var amazonSinkFilePath = "SomeLogFile.txt";
var getArgs = new GetObjectArgs().WithBucket(minIoSourceBucket)
.WithObject(minIoSourceFilePath)
.WithCallbackStream(async stream =>
{
var memoryStream = new MemoryStream();
stream.CopyTo(memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
await PutObjectAsync(amazonClient, amazonSinkBucket, amazonSinkFilePath,
memoryStream, memoryStream.Length, "application/octet-stream");
});
var getResult = await minIoClient.GetObjectAsync(getArgs);
Console.ReadKey();
}
public static async Task PutObjectAsync(MinioClient mediaClient, string bucketName, string objectName, Stream data, long size, string contentType = null,
Dictionary<string, string> metaData = null, CancellationToken cancellationToken = new CancellationToken())
{
var obj = new PutObjectArgs()
.WithBucket(bucketName)
.WithObject(objectName)
.WithStreamData(data)
.WithObjectSize(size);
if (!string.IsNullOrWhiteSpace(contentType))
{
obj.WithContentType(contentType);
}
if (!(metaData is null))
{
obj.WithHeaders(metaData);
}
await mediaClient.PutObjectAsync(obj, cancellationToken);
}
}
}
I have diagnosed this to the CreateRequest method, the code does not load the region if it is a PUT request. This was added to prevent createBucket requests from failing however it means the region is not loaded for this put object request
I will raise a PR with my code fix for this
Metadata
Metadata
Assignees
Labels
No labels