Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
3.11.0
-
None
-
Unknown
Description
I can't upload files to S3 when the bucket has an object lock because it requires the CONTENT-MD5 header to be set on the message.
The AWS2S3Producer seems to have a bug where it only sets "Content-Md5" in the objectMetadata, but I think it needs to do something like:
putObjectRequest.contentMD5(exchange.getIn().getHeader(AWS2S3Constants.CONTENT_MD5, String.class))
when building the putRequest, similar to how the cannedACL is handled here: https://github.com/apache/camel/blob/main/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java#L296 rather than just putting it in the objectMetadata.
I have a workaround for now, I'm creating a bean that overrides the S3Client and configures it to always generate the MD5 hash.
My workaround:
bean() { S3Client.builder() .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create(accessKey, secretKey))) .region(Region.of(region)) .overrideConfiguration(ClientOverrideConfiguration.builder().putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create() ).build()) .build() }