Helper class to connect to Amazon aws S3 and store files.
Inheritance: IDisposable
        public void PutFileObjectTest()
        {
            // Get the client details from the stored client details (rather than embed secret keys in the test).
            // Ensure that your AWS/Secret keys have been stored before running.
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            S3Helper helper = new S3Helper(clientDetails);

            const string bucketName = "ExampleTestBucket";
            const string key = "ExampleObject";

            // Put a simple text object into the bucket to delete.
            helper.CreateBucket(bucketName);
            try
            {

                helper.PutFileObject(bucketName, key, @"C:\Temp\IMD.WebSite.zip");
            }
            catch (Exception ex)
            {

            }
            finally
            {
                //helper.DeleteObject(bucketName, key);
                //helper.DeleteBucket(bucketName);
            }
        }
        public void DeleteObject_Should_Succeed()
        {
            // Get the client details from the stored client details (rather than embed secret keys in the test).
            // Ensure that your AWS/Secret keys have been stored before running.
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            S3Helper helper = new S3Helper(clientDetails);

            const string bucketName = "ExampleTestBucket";
            const string key = "ExampleObject";

            // Put a simple text object into the bucket to delete.
            helper.CreateBucket(bucketName);
            helper.PutTextObject(bucketName, key, "Example text to store in the object");

            try
            {
                helper.DeleteObject(bucketName, key);
            }
            finally
            {
                helper.DeleteBucket(bucketName);
            }
        }
 private void CreateBucket(AwsClientDetails clientDetails)
 {
     using (var helper = new S3Helper(clientDetails))
     {
         helper.CreateBucket(BucketName);
         Log.LogMessage(MessageImportance.Normal, "Created S3 Bucket {0}", BucketName);
     }
 }
 private void PutTextObject(AwsClientDetails clientDetails)
 {
     using (var helper = new S3Helper(clientDetails))
     {
         helper.PutTextObject(BucketName, Key, Text);
         Log.LogMessage(MessageImportance.Normal, "Put object {0} into bucket {1}", Key, BucketName);
     }
 }
 private void SetAcl(AwsClientDetails clientDetails)
 {
     using (var helper = new S3Helper(clientDetails))
     {
         helper.SetAcl(BucketName, CannedAcl, Key);
         Log.LogMessage(MessageImportance.High, "Setting Acl {0} on object {0} in bucket {1}", CannedAcl, Key, BucketName);
     }
 }
 private void CreateBucket(AwsClientDetails clientDetails)
 {
     using (var helper = new S3Helper(clientDetails))
     {
         helper.DeleteObject(BucketName, Key);
         Log.LogMessage(MessageImportance.High, "Deleted AWS S3 Object {0} from bucket {1} ", Key, BucketName);
     }
 }
 private void DeleteBucket(AwsClientDetails clientDetails)
 {
     using (var helper = new S3Helper(clientDetails))
     {
         helper.DeleteBucket(BucketName);
         Log.LogMessage(MessageImportance.High, "Deleted S3 Bucket {0}", BucketName);
     }
 }
Exemple #8
0
 private void DeleteBucket(AwsClientDetails clientDetails)
 {
     using (var helper = new S3Helper(clientDetails))
     {
         helper.DeleteBucket(BucketName);
         Log.LogMessage(MessageImportance.High, "Deleted S3 Bucket {0}", BucketName);
     }
 }
 private void PutFileObject(AwsClientDetails clientDetails)
 {
     using (var helper = new S3Helper(clientDetails))
     {
         helper.PutFileObject(BucketName, Key, FileName);
         Log.LogMessage(MessageImportance.Normal, "Put file {0} into object {0} in bucket {1}", FileName, Key, BucketName);
     }
 }
Exemple #10
0
 private void SetAcl(AwsClientDetails clientDetails)
 {
     using (var helper = new S3Helper(clientDetails))
     {
         helper.SetAcl(BucketName, CannedAcl, Key);
         Log.LogMessage(MessageImportance.High, "Setting Acl {0} on object {0} in bucket {1}", CannedAcl, Key, BucketName);
     }
 }
 private void PublishFiles(AwsClientDetails clientDetails)
 {
     using (var helper = new S3Helper(clientDetails))
     {
         helper.Publish(SourceFiles, DestinationBucket, DestinationFolder, PublicRead);
         Log.LogMessage(MessageImportance.Normal, "Published {0} files to S3", SourceFiles.Length);
     }
 }
Exemple #12
0
 private void PublishFiles(AwsClientDetails clientDetails)
 {
     using (var helper = new S3Helper(clientDetails))
     {
         helper.Publish(SourceFiles, DestinationBucket, DestinationFolder, PublicRead);
         Log.LogMessage(MessageImportance.Normal, "Published {0} files to S3", SourceFiles.Length);
     }
 }
 private void CreateBucket(AwsClientDetails clientDetails)
 {
     using (var helper = new S3Helper(clientDetails))
     {
         helper.CreateBucket(BucketName);
         Log.LogMessage(MessageImportance.Normal, "Created S3 Bucket {0}", BucketName);
     }
 }
 private void CreateBucket(AwsClientDetails clientDetails)
 {
     using (var helper = new S3Helper(clientDetails))
     {
         helper.DeleteObject(BucketName, Key);
         Log.LogMessage(MessageImportance.High, "Deleted AWS S3 Object {0} from bucket {1} ", Key, BucketName);
     }
 }
 private void CleanBucket(AwsClientDetails clientDetails)
 {
     using (var helper = new S3Helper(clientDetails))
     {
         helper.CleanBucket(BucketName);
         Log.LogMessage(MessageImportance.Normal, "Deleted all files on AWS S3 from bucket {0} ", BucketName);
     }
 }
 private void DownloadFile(AwsClientDetails clientDetails)
 {
     using (var helper = new S3Helper(clientDetails))
     {
         Log.LogMessage(MessageImportance.Normal, "Downloading Sourcefiles={0} to {1}", Join(FilesName), SavePath);
         helper.DownloadFile(BucketName, FilesName, SavePath, Version);
         //Log.LogMessage(MessageImportance.Normal, "Deleted all files on AWS S3 from bucket {0} ", BucketName);
     }
 }
        public void DeleteBucket_Should_Succeed()
        {
            // Get the client details from the stored client details (rather than embed secret keys in the test).
            // Ensure that your AWS/Secret keys have been stored before running.
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            S3Helper helper = new S3Helper(clientDetails);

            helper.DeleteBucket("ExampleTestBucket");
        }