Пример #1
0
        public void SetAcl_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.SetAcl(bucketName, "AuthenticatedRead", key);
            }
            finally
            {
                helper.DeleteObject(bucketName, key);
                helper.DeleteBucket(bucketName);
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        public void CreateBucket_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.CreateBucket("ExampleTestBucket");
        }
Пример #4
0
        static int Main(string[] args)
        {
            if (args.Length < 3)
            {
                Console.WriteLine("Usage <bucket name> <access key> <secret key> [<environment>]");
                return(-1);
            }

            // Assume the arguments are in the correct order
            // If the access/secret keys are wrong, it won't
            // matter anyway
            string bucket = args[0];
            string aKey   = args[1];
            string sKey   = args[2];
            string env    = string.Empty;

            // See if an environment is set
            if (args.Length > 3)
            {
                env = args[3];
            }

            using (var client = S3Helper.S3Client(aKey, sKey))
            {
                S3Helper.CreateBucket(client, bucket, "Packages");

                // Grab AWS Credentials
                var credentials = new BasicAWSCredentials(aKey, sKey);
                using (var dynamo = new AmazonDynamoDBClient(credentials, RegionEndpoint.USWest2))
                {
                    //ConfigureTableMeta(dynamo, env);
                    AddLabelToInvalidReports(dynamo, env);
                }

                return(0);
            }
        }