`CopyObject` S3 compatibility
I tried Min.io .net client which works if you have no nesting in your copy:
var srcArgs = new CopySourceObjectArgs().WithBucket("sourceBucket").WithObject("file.txt");
var copyArgs = new CopyObjectArgs().WithBucket("targetBucket").WithObject("file.txt").WithCopyObjectSource(srcArgs);
await minioClient.CopyObjectAsync(copyArgs);
But this fails:
var srcArgs = new CopySourceObjectArgs().WithBucket("sourceBucket").WithObject("folder/file.txt");
var copyArgs = new CopyObjectArgs().WithBucket("targetBucket").WithObject("folder/file.txt").WithCopyObjectSource(srcArgs);
await minioClient.CopyObjectAsync(copyArgs);
As an alternative, what I ended up doing is running rclone inside a process:
var psi = new ProcessStartInfo();
psi.FileName = "C:\pathToRClone\rclone.exe";
psi.Arguments = "connection:sourceBucket/folder/file.txt connection:targetbucket/folder";
psi.RedirectStandardError = true;
psi.UseShellExecute = false;
var process = Process.Start(psi);
var standardErrorTask = process.StandardError.ReadToEndAsync();
var internalTimeOut = TimeSpan.FromHours(1);
var timeoutSignal = new CancellationTokenSource(internalTimeOut);
try
{
await process.WaitForExitAsync(timeoutSignal.Token);
var standardError = await standardErrorTask;
if (process.ExitCode != 0)
{
throw new Exception($"Proccess failed. Exit Code {process.ExitCode}. StdError {standardError}");
}
}
catch
{
process.Kill();
process.WaitForExit();
throw;
}