// Copy object from one bucket to another public async static Task Run(Minio.MinioClient minio, string fromBucketName = "from-bucket-name", string fromObjectName = "from-object-name", string destBucketName = "dest-bucket", string destObjectName = "to-object-name") { try { Console.Out.WriteLine("Running example for API: CopyObjectAsync"); // Optionally pass copy conditions to replace metadata on destination object with custom metadata CopyConditions copyCond = new CopyConditions(); copyCond.SetReplaceMetadataDirective(); // set custom metadata var metadata = new Dictionary <string, string> { { "Content-Type", "application/css" }, { "X-Amz-Meta-Mynewkey", "my-new-value" } }; await minio.CopyObjectAsync(fromBucketName, fromObjectName, destBucketName, destObjectName, copyConditions : copyCond, metadata : metadata); Console.Out.WriteLine("Copied object {0} from bucket {1} to bucket {2}", fromObjectName, fromBucketName, destBucketName); Console.Out.WriteLine(); } catch (Exception e) { Console.WriteLine("[Bucket] Exception: {0}", e); } }
// Copy object from one bucket to another public async static Task Run(Minio.MinioClient minio, string fromBucketName = "from-bucket-name", string fromObjectName = "from-object-name", string destBucketName = "dest-bucket", string destObjectName = "to-object-name", ServerSideEncryption sseSrc = null, ServerSideEncryption sseDest = null) { try { Console.Out.WriteLine("Running example for API: CopyObjectAsync"); // Optionally pass copy conditions await minio.CopyObjectAsync(fromBucketName, fromObjectName, destBucketName, destObjectName, copyConditions : null, sseSrc : sseSrc, sseDest : sseDest); Console.Out.WriteLine("Copied object {0} from bucket {1} to bucket {2}", fromObjectName, fromBucketName, destBucketName); Console.Out.WriteLine(); } catch (Exception e) { Console.WriteLine("[Bucket] Exception: {0}", e); } }
public async Task CopyObject( string bucketName, string objectName, string destBucketName, string destObjectName = null, Dictionary <string, string> metadata = null, CancellationToken token = default) { await EnsureBucketExists(destBucketName, token); await _client.CopyObjectAsync(bucketName, objectName, destBucketName, destObjectName, metadata : metadata, cancellationToken : token); }