murtaza sanjeliwala murtaza sanjeliwala - 2 months ago 18
C# Question

How to copy/move object of amazon s3 having multi level childs to destination?

I have to implement copy/move functionality of amazon s3 objects. but in case of objects with multilevel childs i am unable to copy/move all objects.

Answer

you can use S3DirectoryInfo.Move and S3DirectoryInfo.Copy methods see the examples below (AWSSDK.Core and AWSSDK.S3 Version 3.1.0.0):enter code here

AmazonS3Config cfg = new AmazonS3Config();
cfg.RegionEndpoint = Amazon.RegionEndpoint.EUCentral1;//bucket location
string bucketName = "source bucket";
AmazonS3Client s3Client = new AmazonS3Client("your accessKey", "your secretKey", cfg);

S3DirectoryInfo source = new S3DirectoryInfo(s3Client, bucketName, "sourceFolder");
 string bucketName2 = "destination butcket";               
    S3DirectoryInfo destination = new S3DirectoryInfo(s3Client, bucketName2);
  source.CopyTo(destination); 
// or 
source.MoveTo(destination);

Probably it can help you.

Comments