protected override void ProcessPreRequestHandlers(AmazonWebServiceRequest request)
{
base.ProcessPreRequestHandlers(request);
var putObjectRequest = request as PutObjectRequest;
if (putObjectRequest != null)
{
if (this.amazonS3CryptoConfig.StorageMode == CryptoStorageMode.InstructionFile)
{
GenerateEncryptedObjectRequestUsingInstructionFile(putObjectRequest);
}
else
{
GenerateEncryptedObjectRequestUsingMetadata(putObjectRequest);
}
}
var initiateMultiPartRequest = request as InitiateMultipartUploadRequest;
if (initiateMultiPartRequest != null)
{
EncryptionInstructions instructions = EncryptionUtils.GenerateInstructions(this.encryptionMaterials);
if (this.amazonS3CryptoConfig.StorageMode == CryptoStorageMode.ObjectMetadata)
{
EncryptionUtils.UpdateMetadataWithEncryptionInstructions(initiateMultiPartRequest, instructions);
}
initiateMultiPartRequest.EnvelopeKey = instructions.EnvelopeKey;
initiateMultiPartRequest.IV = instructions.InitializationVector;
}
var uploadPartRequest = request as UploadPartRequest;
if (uploadPartRequest != null)
{
GenerateEncryptedUploadPartRequest(uploadPartRequest);
}
}