Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-16936

camel-aws2-s3: Not setting CONTENT-MD5 header which breaks putObject with object locks

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.11.0
    • 3.7.6, 3.11.3, 3.12.0
    • camel-aws2
    • 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()
      }
      

       

      Attachments

        Activity

          People

            acosentino Andrea Cosentino
            DylanSale Dylan Sale
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: