Amazon.S3.Encryption.EncryptionUtils.AddUnencryptedContentLengthToMetadata C# (CSharp) Method

AddUnencryptedContentLengthToMetadata() static private method

Adds UnEncrypted content length to object metadata
static private AddUnencryptedContentLengthToMetadata ( PutObjectRequest request ) : void
request Amazon.S3.Model.PutObjectRequest
return void
        internal static void AddUnencryptedContentLengthToMetadata(PutObjectRequest request)
        {
            long originalLength = request.InputStream.Length;
            request.Metadata.Add(unEncryptedContentLength, originalLength.ToString(CultureInfo.InvariantCulture));
        }

Usage Example

        /// <summary>
        /// Updates the request where the metadata contains encryption information
        /// and the input stream contains the encrypted object contents.
        /// </summary>
        /// <param name="putObjectRequest">
        /// The request whose contents are to be encrypted.
        /// </param>
        private void GenerateEncryptedObjectRequestUsingMetadata(PutObjectRequest putObjectRequest)
        {
            // Create instruction
            EncryptionInstructions instructions = EncryptionUtils.GenerateInstructions(this.encryptionMaterials);

            EncryptionUtils.AddUnencryptedContentLengthToMetadata(putObjectRequest);

            // Encrypt the object data with the instruction
            putObjectRequest.InputStream = EncryptionUtils.EncryptRequestUsingInstruction(putObjectRequest.InputStream, instructions);

            // Update the metadata
            EncryptionUtils.UpdateMetadataWithEncryptionInstructions(putObjectRequest, instructions);
        }
All Usage Examples Of Amazon.S3.Encryption.EncryptionUtils::AddUnencryptedContentLengthToMetadata