This class extends the AmazonS3Client and provides client side encryption when reading or writing S3 objects.
상속: AmazonS3Client
예제 #1
0
        public static void Initialize(TestContext a)
        {
            s3EncryptionClientMetadataMode = new AmazonS3EncryptionClient(encryptionMaterials);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientMetadataMode);            

            AmazonS3CryptoConfiguration config = new AmazonS3CryptoConfiguration()
            {
                StorageMode = CryptoStorageMode.InstructionFile
            };
            s3EncryptionClientFileMode = new AmazonS3EncryptionClient(config, encryptionMaterials);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientFileMode);            


            using (StreamWriter writer = File.CreateText(fileName))
            {
                writer.Write(sampleContent);
            }
            bucketName = S3TestUtils.CreateBucket(s3EncryptionClientFileMode);
        }
예제 #2
0
        private static void TestGet2(string key, string uploadedFile, AmazonS3EncryptionClient s3EncryptionClient)
        {
            GetObjectRequest getObjectRequest = new GetObjectRequest
            {
                BucketName = bucketName,
                Key = key
            };

            var destinationFile = fileName + ".downloaded";
            using (GetObjectResponse getObjectResponse = s3EncryptionClient.GetObject(getObjectRequest))
            {
                getObjectResponse.WriteResponseStreamToFile(destinationFile);
            }

            var originalMd5 = HashFile(uploadedFile);
            var downloadedMd5 = HashFile(destinationFile);
            Assert.AreEqual(originalMd5, downloadedMd5);
        }
예제 #3
0
        private static void TestGet(string key, string uploadedData, AmazonS3EncryptionClient s3EncryptionClient)
        {
            GetObjectRequest getObjectRequest = new GetObjectRequest
            {
                BucketName = bucketName,
                Key = key
            };

            using (GetObjectResponse getObjectResponse = s3EncryptionClient.GetObject(getObjectRequest))
            {
                using (var stream = getObjectResponse.ResponseStream)
                using (var reader = new StreamReader(stream))
                {
                    string data = reader.ReadToEnd();
                    Assert.AreEqual(uploadedData, data);
                }
            }
        }