Wednesday, April 10, 2013

Amazon S3 file download

A code snippet to download files from S3 by providing rootbucket, access key and secret key.


 AmazonS3 _client;  
 using (_client = Amazon.AWSClientFactory.CreateAmazonS3Client(accesskey, secretkey))  
 {  
      var util = new TransferUtility(_client);  
      var request = new TransferUtilityDownloadRequest()  
           .WithBucketName(rootbucket)  
           //e.g. full path is sohail/video/123.mp4  
           // root bucket is sohail, video/123.mp4 is WithKey  
     .WithKey(at which location have to download S3 file)   
           // Where to download location of hard disk.  
     .WithFilePath(ToDownloadPath);  
   util.Download(request);  
 }  

No comments:

Post a Comment