コード例 #1
0
        public ThreeSharpFormSample()
        {
            InitializeComponent();

            this.transfers = new BindingList <TransferInfo>();
            this.dataGridViewStatistics.DataSource = transfers;

            bindStatisticsDelegate = new BindStatisticsDelegate(this.BindStatistics);
            listBucketDelegate     = new ListBucketDelegate(this.ListBucket);
            listFolderDelegate     = new ListFolderDelegate(this.ListFolder);
            uploadFileDelegate     = new UploadFileDelegate(this.UploadFile);
            downloadFileDelegate   = new DownloadFileDelegate(this.DownloadFile);

            this.basePath = "C:\\";

            config = new ThreeSharpConfig();
            config.AwsAccessKeyID     = Properties.Settings.Default.AwsAccessKeyID;
            config.AwsSecretAccessKey = Properties.Settings.Default.AwsSecretAccessKey;
            config.ConnectionLimit    = 40;
            config.IsSecure           = true;

            // It is necessary to use the SUBDOMAIN CallingFormat for accessing EU buckets
            config.Format = CallingFormat.SUBDOMAIN;

            this.service = new ThreeSharpQuery(config);
        }
コード例 #2
0
        private void UploadToAmazonS3(string videoFile, Guid objectId, Guid userId, string format, VideoVersion videoVersion)
        {
            try
            {
                string keyNamePath = string.Format("{0}/{1}/{2}", userId, Helper.GetMediaFolder(Helper.GetObjectType("Video").NumericId), format);
                if (videoVersion != VideoVersion.None)
                {
                    keyNamePath += string.Format(@"/{0}", videoVersion);
                }
                string keyName = string.Format(@"{0}/{1}.{2}", keyNamePath, objectId, format).ToLower();

                ThreeSharpConfig config = new ThreeSharpConfig();
                config.AwsAccessKeyID     = amazoneS3AKey;
                config.AwsSecretAccessKey = amazoneS3SAKey;
                config.Format             = amazoneS3BucketLocation == "EU" ? CallingFormat.SUBDOMAIN : CallingFormat.REGULAR;

                IThreeSharp      service          = new ThreeSharpQuery(config);
                ObjectAddRequest objectAddRequest = new ObjectAddRequest(amazoneS3Bucket, keyName);
                objectAddRequest.LoadStreamWithFile(videoFile);
                objectAddRequest.Headers.Add("x-amz-acl", "public-read");

                ObjectAddResponse objectAddResponse = service.ObjectAdd(objectAddRequest);
                objectAddResponse.DataStream.Close();
            }
            catch (Exception e)
            {
                throw new Exception("Amazon S3 upload failed: " + e.Message);
            }
        }
コード例 #3
0
        public ThreeSharpQuery(ThreeSharpConfig threeSharpConfig)
        {
            this.config     = threeSharpConfig;
            this.statistics = new ThreeSharpStatistics();

            ServicePointManager.DefaultConnectionLimit = threeSharpConfig.ConnectionLimit;
        }
コード例 #4
0
        public ThreeSharpWrapper(String awsAccessKeyId, String awsSecretAccessKey)
        {
            this.config = new ThreeSharpConfig();
            this.config.AwsAccessKeyID = awsAccessKeyId;
            this.config.AwsSecretAccessKey = awsSecretAccessKey;

            this.service = new ThreeSharpQuery(this.config);
        }
コード例 #5
0
        public ThreeSharpWrapper(String awsAccessKeyId, String awsSecretAccessKey)
        {
            this.config = new ThreeSharpConfig();
            this.config.AwsAccessKeyID     = awsAccessKeyId;
            this.config.AwsSecretAccessKey = awsSecretAccessKey;

            this.service = new ThreeSharpQuery(this.config);
        }
コード例 #6
0
        public ThreeSharpS3Service(string accessKey, string secretKey)
        {
            var config = new ThreeSharpConfig();

            config.AwsAccessKeyID     = accessKey;
            config.AwsSecretAccessKey = secretKey;
            config.IsSecure           = false;

            client = new ThreeSharpQuery(config);
        }
コード例 #7
0
        private long UploadToAmazone(string ConvertedFile, string objectID, string userID)
        {
            long StreamLength = -1;

            try
            {
                //Attention: Key Is case sensitive
                string keyName = userID + "/" + Helper.GetMediaFolder(ObjectType.Video) + "/flv/" + objectID + ".flv";
                keyName = keyName.ToLower();
                ThreeSharpConfig config = new ThreeSharpConfig();
                config.AwsAccessKeyID     = amazoneS3AKey;
                config.AwsSecretAccessKey = amazoneS3SAKey;
                if (amazoneS3BucketLocation == "EU")
                {
                    config.Format = CallingFormat.SUBDOMAIN;
                }
                else
                {
                    config.Format = CallingFormat.REGULAR;
                }
                IThreeSharp      service          = new ThreeSharpQuery(config);
                ObjectAddRequest objectAddRequest = new ObjectAddRequest(amazoneS3Bucket, keyName);
                objectAddRequest.LoadStreamWithFile(ConvertedFile);
                objectAddRequest.Headers.Add("x-amz-acl", "public-read");
                ObjectAddResponse objectAddResponse = service.ObjectAdd(objectAddRequest);
                objectAddResponse.DataStream.Close();
                FileInfo fiUpload = new FileInfo(ConvertedFile);
                StreamLength = (int)fiUpload.Length;
                fiUpload     = null;
            }
            catch (Exception e)
            {
                WriteMonitoringLog(strTransactionID, objectID, BaseActions.VideoConvert, 13, "Amazone S3 upload failed", _4screen.CSB.Common.MonitoringLogState.Aborted, e.Message);
            }
            return(StreamLength);
        }
コード例 #8
0
        static void DemonstrateThreeSharp()
        {
            Console.WriteLine("===========================================");
            Console.WriteLine("Demonstrating the ThreeSharp Library");
            Console.WriteLine("===========================================");

            ThreeSharpConfig config = new ThreeSharpConfig();

            config.AwsAccessKeyID     = awsAccessKeyId;
            config.AwsSecretAccessKey = awsSecretAccessKey;
            config.IsSecure           = false;

            IThreeSharp service = new ThreeSharpQuery(config);

            // Convert the bucket name to lowercase for vanity domains.
            // the bucket must be lower case since DNS is case-insensitive.
            Random r = new Random();
            string testBucketName  = awsAccessKeyId.ToLower() + "-test-bucket" + r.Next(50000).ToString();;
            string testBucketName2 = awsAccessKeyId.ToLower() + "-test-bucket" + r.Next(50000).ToString();;
            string stringKeyName   = "StringObject";


            Console.WriteLine("\n----- Creating Bucket " + testBucketName + " -----");
            using (BucketAddRequest request = new BucketAddRequest(testBucketName))
                using (BucketAddResponse response = service.BucketAdd(request))
                { }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Listing Bucket " + testBucketName + " -----");
            using (BucketListRequest request = new BucketListRequest(testBucketName))
                using (BucketListResponse response = service.BucketList(request))
                {
                    Console.WriteLine(response.StreamResponseToString());
                }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Creating Bucket " + testBucketName2 + " -----");
            using (BucketAddRequest request = new BucketAddRequest(testBucketName2))
                using (BucketAddResponse response = service.BucketAdd(request))
                { }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Listing Bucket " + testBucketName2 + " -----");
            using (BucketListRequest request = new BucketListRequest(testBucketName2))
                using (BucketListResponse response = service.BucketList(request))
                {
                    Console.WriteLine(response.StreamResponseToString());
                }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Adding String Object to " + testBucketName + " -----");
            using (ObjectAddRequest request = new ObjectAddRequest(testBucketName, stringKeyName))
            {
                request.LoadStreamWithString("This is a string object.");
                using (ObjectAddResponse response = service.ObjectAdd(request))
                { }
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Getting String Object -----");
            using (ObjectGetRequest request = new ObjectGetRequest(testBucketName, stringKeyName))
            {
                using (ObjectGetResponse response = service.ObjectGet(request))
                {
                    Console.WriteLine(response.StreamResponseToString());
                }
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Copying String Object to " + testBucketName2 + " -----");
            using (ObjectCopyRequest request = new ObjectCopyRequest(testBucketName, stringKeyName, testBucketName2, stringKeyName + "Copy"))
                using (ObjectCopyResponse response = service.ObjectCopy(request))
                { }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Listing Bucket " + testBucketName2 + " -----");
            using (BucketListRequest request = new BucketListRequest(testBucketName2))
                using (BucketListResponse response = service.BucketList(request))
                {
                    Console.WriteLine(response.StreamResponseToString());
                }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Getting RequestPaymentConfiguration for " + testBucketName2 + " -----");
            using (PaymentGetRequest request = new PaymentGetRequest(testBucketName2))
                using (PaymentGetResponse response = service.PaymentGet(request))
                {
                    Console.WriteLine(response.StreamResponseToString());
                }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Changing RequestPaymentConfiguration for " + testBucketName2 + " -----");
            using (PaymentChangeRequest request = new PaymentChangeRequest(testBucketName2, PaymentChangeRequest.Payer.Requester))
                using (PaymentChangeResponse response = service.PaymentChange(request))
                { }

            Console.WriteLine("\n----- Getting RequestPaymentConfiguration (again) for " + testBucketName2 + " -----");
            using (PaymentGetRequest request = new PaymentGetRequest(testBucketName2))
                using (PaymentGetResponse response = service.PaymentGet(request))
                {
                    Console.WriteLine(response.StreamResponseToString());
                }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Changing RequestPaymentConfiguration for " + testBucketName2 + " -----");
            using (PaymentChangeRequest request = new PaymentChangeRequest(testBucketName2, PaymentChangeRequest.Payer.BucketOwner))
                using (PaymentChangeResponse response = service.PaymentChange(request))
                { }

            Console.WriteLine("\n----- Getting Copied String Object -----");
            using (ObjectGetRequest request = new ObjectGetRequest(testBucketName2, stringKeyName + "Copy"))
            {
                using (ObjectGetResponse response = service.ObjectGet(request))
                {
                    Console.WriteLine(response.StreamResponseToString());
                }
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();


            Console.WriteLine("\n----- Streaming File Object -----");
            using (ObjectAddRequest request = new ObjectAddRequest(testBucketName, uploadFile))
            {
                request.LoadStreamWithFile(uploadPath + uploadFile);
                using (ObjectAddResponse response = service.ObjectAdd(request))
                { }
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Streaming/Encrypting File Object -----");
            using (ObjectAddRequest request = new ObjectAddRequest(testBucketName, uploadFile + "Encrypted"))
            {
                request.LoadStreamWithFile(uploadPath + uploadFile);
                request.EncryptStream(encryptionKey, encryptionIV);
                using (ObjectAddResponse response = service.ObjectAdd(request))
                { }
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Listing Bucket " + testBucketName + " -----");
            using (BucketListRequest request = new BucketListRequest(testBucketName))
                using (BucketListResponse response = service.BucketList(request))
                {
                    Console.WriteLine(response.StreamResponseToString());
                }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Streaming File to Disk -----");
            using (ObjectGetRequest request = new ObjectGetRequest(testBucketName, uploadFile))
                using (ObjectGetResponse response = service.ObjectGet(request))
                {
                    response.StreamResponseToFile(downloadPath + uploadFile);
                }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Streaming/Decrypting File to Disk -----");
            using (ObjectGetRequest request = new ObjectGetRequest(testBucketName, uploadFile + "Encrypted"))
                using (ObjectGetResponse response = service.ObjectGet(request))
                {
                    response.DecryptStream(encryptionKey, encryptionIV);
                    response.StreamResponseToFile(downloadPath + "decrypted-" + uploadFile);
                }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Query String Authorization Example -----");
            using (UrlGetRequest request = new UrlGetRequest(testBucketName, uploadFile))
            {
                request.ExpiresIn = 60 * 1000;
                using (UrlGetResponse response = service.UrlGet(request))
                {
                    Console.WriteLine("Try this url in your web browser (it will only work for 60 seconds)\n");
                    Console.WriteLine(response.StreamResponseToString());
                }
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Adding String Object with Metadata and Public Read ACL -----");
            using (ObjectAddRequest request = new ObjectAddRequest(testBucketName, stringKeyName + "Public"))
            {
                request.LoadStreamWithString("This is a publicly readable test.");
                request.MetaData.Add("blah", "foo");
                request.Headers.Add("x-amz-acl", "private");
                //request.Headers.Add("x-amz-acl", "public-read");
                //request.Headers.Add("x-amz-acl", "public-read-write");
                //request.Headers.Add("x-amz-acl", "authenticated-read");
                using (ObjectAddResponse response = service.ObjectAdd(request))
                { }
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Getting Object's ACL -----");
            using (ACLGetRequest request = new ACLGetRequest(testBucketName, stringKeyName + "Public"))
                using (ACLGetResponse response = service.ACLGet(request))
                {
                    string output = response.StreamResponseToString();
                    Console.WriteLine(output);
                }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Changing Object's ACL -----");
            using (ACLChangeRequest request = new ACLChangeRequest(testBucketName, stringKeyName + "Public", "public-read"))
                using (ACLChangeResponse response = service.ACLChange(request))
                { }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Getting Object's ACL -----");
            using (ACLGetRequest request = new ACLGetRequest(testBucketName, stringKeyName + "Public"))
                using (ACLGetResponse response = service.ACLGet(request))
                {
                    string output = response.StreamResponseToString();
                    Console.WriteLine(output);
                }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Deleting Objects -----");
            using (ObjectDeleteRequest request = new ObjectDeleteRequest(testBucketName, stringKeyName))
                using (ObjectDeleteResponse response = service.ObjectDelete(request))
                { }
            using (ObjectDeleteRequest request = new ObjectDeleteRequest(testBucketName2, stringKeyName + "Copy"))
                using (ObjectDeleteResponse response = service.ObjectDelete(request))
                { }
            using (ObjectDeleteRequest request = new ObjectDeleteRequest(testBucketName, uploadFile))
                using (ObjectDeleteResponse response = service.ObjectDelete(request))
                { }
            using (ObjectDeleteRequest request = new ObjectDeleteRequest(testBucketName, uploadFile + "Encrypted"))
                using (ObjectDeleteResponse response = service.ObjectDelete(request))
                { }
            using (ObjectDeleteRequest request = new ObjectDeleteRequest(testBucketName, stringKeyName + "Public"))
                using (ObjectDeleteResponse response = service.ObjectDelete(request))
                { }

            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Listing Bucket " + testBucketName + " -----");
            using (BucketListRequest request = new BucketListRequest(testBucketName))
                using (BucketListResponse response = service.BucketList(request))
                {
                    Console.WriteLine(response.StreamResponseToString());
                }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Listing Bucket " + testBucketName2 + " -----");
            using (BucketListRequest request = new BucketListRequest(testBucketName2))
                using (BucketListResponse response = service.BucketList(request))
                {
                    Console.WriteLine(response.StreamResponseToString());
                }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Listing All My Buckets -----");
            using (BucketListRequest request = new BucketListRequest(null))
                using (BucketListResponse response = service.BucketList(request))
                {
                    Console.WriteLine(response.StreamResponseToString());
                }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Deleting Bucket " + testBucketName + " -----");
            using (BucketDeleteRequest request = new BucketDeleteRequest(testBucketName))
                using (BucketDeleteResponse response = service.BucketDelete(request))
                { }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Deleting Bucket " + testBucketName2 + " -----");
            using (BucketDeleteRequest request = new BucketDeleteRequest(testBucketName2))
                using (BucketDeleteResponse response = service.BucketDelete(request))
                { }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Listing All My Buckets -----");
            using (BucketListRequest request = new BucketListRequest(null))
                using (BucketListResponse response = service.BucketList(request))
                {
                    Console.WriteLine(response.StreamResponseToString());
                }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\nTotal data transfers: " + service.GetTransferInfos().Length.ToString());
            Console.WriteLine("Total bytes uploaded: " + service.GetTotalBytesUploaded().ToString());
            Console.WriteLine("Total bytes downloaded: " + service.GetTotalBytesDownloaded().ToString());
            Console.WriteLine("\npress enter >");
            Console.ReadLine();
        }
コード例 #9
0
        static void DemonstrateThreeSharp()
        {
            Console.WriteLine("===========================================");
            Console.WriteLine("Demonstrating the ThreeSharp Library");
            Console.WriteLine("===========================================");

            ThreeSharpConfig config = new ThreeSharpConfig();
            config.AwsAccessKeyID = awsAccessKeyId;
            config.AwsSecretAccessKey = awsSecretAccessKey;

            IThreeSharp service = new ThreeSharpQuery(config);

            // Convert the bucket name to lowercase for vanity domains.
            // the bucket must be lower case since DNS is case-insensitive.
            Random r = new Random();
            string testBucketName = awsAccessKeyId.ToLower() + "-test-bucket" + r.Next(50000).ToString();;
            string testBucketName2 = awsAccessKeyId.ToLower() + "-test-bucket" + r.Next(50000).ToString(); ;
            string stringKeyName = "StringObject";
            string encryptedFileKeyName = "EncryptedFileObject";


            Console.WriteLine("\n----- Creating Bucket " + testBucketName + " -----");
            using (BucketAddRequest request = new BucketAddRequest(testBucketName))
            using (BucketAddResponse response = service.BucketAdd(request))
            { }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Listing Bucket " + testBucketName + " -----");
            using (BucketListRequest request = new BucketListRequest(testBucketName))
            using (BucketListResponse response = service.BucketList(request))
            {
                Console.WriteLine(response.StreamResponseToString());
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Creating Bucket " + testBucketName2 + " -----");
            using (BucketAddRequest request = new BucketAddRequest(testBucketName2))
            using (BucketAddResponse response = service.BucketAdd(request))
            { }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Listing Bucket " + testBucketName2 + " -----");
            using (BucketListRequest request = new BucketListRequest(testBucketName2))
            using (BucketListResponse response = service.BucketList(request))
            {
                Console.WriteLine(response.StreamResponseToString());
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Adding String Object to " + testBucketName + " -----");
            using (ObjectAddRequest request = new ObjectAddRequest(testBucketName, stringKeyName))
            {
                request.LoadStreamWithString("This is a string object.");
                using (ObjectAddResponse response = service.ObjectAdd(request))
                { }
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Getting String Object -----");
            using (ObjectGetRequest request = new ObjectGetRequest(testBucketName, stringKeyName))
            {
                using (ObjectGetResponse response = service.ObjectGet(request))
                {
                    Console.WriteLine(response.StreamResponseToString());
                }
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Copying String Object to " + testBucketName2 + " -----");
            using (ObjectCopyRequest request = new ObjectCopyRequest(testBucketName, stringKeyName, testBucketName2, stringKeyName + "Copy"))
            using (ObjectCopyResponse response = service.ObjectCopy(request))
            {
                int i = 0;
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Listing Bucket " + testBucketName2 + " -----");
            using (BucketListRequest request = new BucketListRequest(testBucketName2))
            using (BucketListResponse response = service.BucketList(request))
            {
                Console.WriteLine(response.StreamResponseToString());
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Getting Copied String Object -----");
            using (ObjectGetRequest request = new ObjectGetRequest(testBucketName2, stringKeyName + "Copy"))
            {
                using (ObjectGetResponse response = service.ObjectGet(request))
                {
                    Console.WriteLine(response.StreamResponseToString());
                }
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();


            Console.WriteLine("\n----- Streaming File Object -----");
            using (ObjectAddRequest request = new ObjectAddRequest(testBucketName, uploadFile))
            {
                request.LoadStreamWithFile(uploadPath + uploadFile);
                using (ObjectAddResponse response = service.ObjectAdd(request))
                { }
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Streaming/Encrypting File Object -----");
            using (ObjectAddRequest request = new ObjectAddRequest(testBucketName, uploadFile + "Encrypted"))
            {
                request.LoadStreamWithFile(uploadPath + uploadFile);
                request.EncryptStream(encryptionKey, encryptionIV);
                using (ObjectAddResponse response = service.ObjectAdd(request))
                { }
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Listing Bucket " + testBucketName + " -----");
            using (BucketListRequest request = new BucketListRequest(testBucketName))
            using (BucketListResponse response = service.BucketList(request))
            {
                Console.WriteLine(response.StreamResponseToString());
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Streaming File to Disk -----");
            using (ObjectGetRequest request = new ObjectGetRequest(testBucketName, uploadFile))
            using (ObjectGetResponse response = service.ObjectGet(request))
            {
                response.StreamResponseToFile(downloadPath + uploadFile);
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Streaming/Decrypting File to Disk -----");
            using (ObjectGetRequest request = new ObjectGetRequest(testBucketName, uploadFile + "Encrypted"))
            using (ObjectGetResponse response = service.ObjectGet(request))
            {
                response.DecryptStream(encryptionKey, encryptionIV);
                response.StreamResponseToFile(downloadPath + "decrypted-" + uploadFile);
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Query String Authorization Example -----");
            using (UrlGetRequest request = new UrlGetRequest(testBucketName, uploadFile))
            {
                request.ExpiresIn = 60 * 1000;
                using (UrlGetResponse response = service.UrlGet(request))
                {
                    Console.WriteLine("Try this url in your web browser (it will only work for 60 seconds)\n");
                    Console.WriteLine(response.StreamResponseToString());
                }
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Adding String Object with Metadata and Public Read ACL -----");
            using (ObjectAddRequest request = new ObjectAddRequest(testBucketName, stringKeyName + "Public"))
            {
                request.LoadStreamWithString("This is a publicly readable test.");
                request.MetaData.Add("blah", "foo");
                //request.Headers.Add("x-amz-acl", "private");
                request.Headers.Add("x-amz-acl", "public-read");
                //request.Headers.Add("x-amz-acl", "public-read-write");
                //request.Headers.Add("x-amz-acl", "authenticated-read");
                using (ObjectAddResponse response = service.ObjectAdd(request))
                { }
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Getting Object's ACL -----");
            using (ACLGetRequest request = new ACLGetRequest(testBucketName, stringKeyName + "Public"))
            using (ACLGetResponse response = service.ACLGet(request))
            {
                Console.WriteLine(response.StreamResponseToString());
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Deleting Objects -----");
            using (ObjectDeleteRequest request = new ObjectDeleteRequest(testBucketName, stringKeyName))
            using (ObjectDeleteResponse response = service.ObjectDelete(request))
            { }
            using (ObjectDeleteRequest request = new ObjectDeleteRequest(testBucketName2, stringKeyName + "Copy"))
            using (ObjectDeleteResponse response = service.ObjectDelete(request))
            { }
            using (ObjectDeleteRequest request = new ObjectDeleteRequest(testBucketName, uploadFile))
            using (ObjectDeleteResponse response = service.ObjectDelete(request))
            { }
            using (ObjectDeleteRequest request = new ObjectDeleteRequest(testBucketName, uploadFile + "Encrypted"))
            using (ObjectDeleteResponse response = service.ObjectDelete(request))
            { }
            using (ObjectDeleteRequest request = new ObjectDeleteRequest(testBucketName, stringKeyName + "Public"))
            using (ObjectDeleteResponse response = service.ObjectDelete(request))
            { }

            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Listing Bucket " + testBucketName + " -----");
            using (BucketListRequest request = new BucketListRequest(testBucketName))
            using (BucketListResponse response = service.BucketList(request))
            {
                Console.WriteLine(response.StreamResponseToString());
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Listing Bucket " + testBucketName2 + " -----");
            using (BucketListRequest request = new BucketListRequest(testBucketName2))
            using (BucketListResponse response = service.BucketList(request))
            {
                Console.WriteLine(response.StreamResponseToString());
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Listing All My Buckets -----");
            using (BucketListRequest request = new BucketListRequest(null))
            using (BucketListResponse response = service.BucketList(request))
            {
                Console.WriteLine(response.StreamResponseToString());
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Deleting Bucket " + testBucketName + " -----");
            using (BucketDeleteRequest request = new BucketDeleteRequest(testBucketName))
            using (BucketDeleteResponse response = service.BucketDelete(request))
            { }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Deleting Bucket " + testBucketName2 + " -----");
            using (BucketDeleteRequest request = new BucketDeleteRequest(testBucketName2))
            using (BucketDeleteResponse response = service.BucketDelete(request))
            { }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\n----- Listing All My Buckets -----");
            using (BucketListRequest request = new BucketListRequest(null))
            using (BucketListResponse response = service.BucketList(request))
            {
                Console.WriteLine(response.StreamResponseToString());
            }
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

            Console.WriteLine("\nTotal data transfers: " + service.GetTransfers().Length.ToString());
            Console.WriteLine("Total bytes uploaded: " + service.GetTotalBytesUploaded().ToString());
            Console.WriteLine("Total bytes downloaded: " + service.GetTotalBytesDownloaded().ToString());
            Console.WriteLine("\npress enter >");
            Console.ReadLine();

        }