LP13
LP13

Reputation: 34109

Uploading a directory to AWS S3

I want to upload a directory to AWS S3 based on AWS documentation here

  TransferUtility directoryTransferUtility =
                new TransferUtility(new AmazonS3Client(Amazon.RegionEndpoint.USEast1));


    directoryTransferUtility.UploadDirectory(directoryPath,
                                                     existingBucketName);

In order to use above API i need RegionEndPoint and BucketName. Lets say i have path in the following format
https://mybucketname.s3-us-west-2.amazonaws.com/mykey/

How do i upload a directory to this path?

I know I can parse the path and get RegionEndPoint and BucketName and use those values in the API. But i was wondering is there any API method available which takes the above path and uploads the objects to that path? The path already contains bucketname and regionendpoint.

Upvotes: 0

Views: 170

Answers (1)

Sailesh Kotha
Sailesh Kotha

Reputation: 2099

Yes, you can use the below object to do that. It returns Bucket, IsPathStyle, Key and Region.

Amazon.S3.Util.AmazonS3Uri

For more information click on http://docs.aws.amazon.com/sdkfornet/v3/apidocs/index.html?page=S3/TS3UtilS3Uri.html&tocid=Amazon_S3_Util_AmazonS3Uri

Upvotes: 1

Related Questions