You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2022/01/13 10:52:26 UTC

[camel] branch camel-3.14.x updated (8b7ad5f -> 4eb8788)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch camel-3.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 8b7ad5f  CAMEL-17454: camel-undertow - Fix duplicate content-type header when using with rest component as producer to call external rest services.
     new b7327d6  CAMEL-17358 - AWS SDK2 Producer does not set the Content Type at all
     new 842cdf1  CAMEL-17358 - AWS SDK2 Producer does not set the Content Type at all
     new 4eb8788  CAMEL-17358 - AWS SDK2 Producer does not set the Content Type at all - Fix multipart upload too

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/component/aws2/s3/AWS2S3Producer.java    | 10 ++++++++
 .../integration/S3MultipartUploadOperationIT.java  | 27 ++++++++++++++++++++++
 .../s3/integration/S3SimpleUploadOperationIT.java  | 25 ++++++++++++++++++++
 3 files changed, 62 insertions(+)

[camel] 03/03: CAMEL-17358 - AWS SDK2 Producer does not set the Content Type at all - Fix multipart upload too

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch camel-3.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 4eb87887596930b46d5a7c9f56b245184bbf41b1
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jan 13 11:36:07 2022 +0100

    CAMEL-17358 - AWS SDK2 Producer does not set the Content Type at all - Fix multipart upload too
---
 .../camel/component/aws2/s3/AWS2S3Producer.java    |  5 ++++
 .../integration/S3MultipartUploadOperationIT.java  | 27 ++++++++++++++++++++++
 .../s3/integration/S3SimpleUploadOperationIT.java  |  3 ++-
 3 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java
index f5baf2b..658398d 100644
--- a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java
+++ b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java
@@ -171,6 +171,11 @@ public class AWS2S3Producer extends DefaultProducer {
             createMultipartUploadRequest.acl(acl.toString());
         }
 
+        String contentType = exchange.getIn().getHeader(AWS2S3Constants.CONTENT_TYPE, String.class);
+        if (contentType != null) {
+            createMultipartUploadRequest.contentType(contentType);
+        }
+
         if (getConfiguration().isUseAwsKMS()) {
             createMultipartUploadRequest.ssekmsKeyId(getConfiguration().getAwsKMSKeyId());
             createMultipartUploadRequest.serverSideEncryption(ServerSideEncryption.AWS_KMS);
diff --git a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3MultipartUploadOperationIT.java b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3MultipartUploadOperationIT.java
index 4d3f6d8..e50d16d 100644
--- a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3MultipartUploadOperationIT.java
+++ b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3MultipartUploadOperationIT.java
@@ -25,7 +25,14 @@ import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.aws2.s3.AWS2S3Constants;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.infra.aws2.clients.AWSSDKClientUtils;
 import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.core.ResponseInputStream;
+import software.amazon.awssdk.services.s3.S3Client;
+import software.amazon.awssdk.services.s3.model.GetObjectRequest;
+import software.amazon.awssdk.services.s3.model.GetObjectResponse;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class S3MultipartUploadOperationIT extends Aws2S3Base {
 
@@ -51,6 +58,26 @@ public class S3MultipartUploadOperationIT extends Aws2S3Base {
         assertMockEndpointsSatisfied();
     }
 
+    @Test
+    public void sendInWithContentType() throws Exception {
+        result.expectedMessageCount(1);
+
+        template.send("direct:putObject", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(AWS2S3Constants.KEY, "camel-content-type.txt");
+                exchange.getIn().setBody(new File("src/test/resources/empty.txt"));
+                exchange.getIn().setHeader(AWS2S3Constants.CONTENT_TYPE, "application/text");
+            }
+        });
+
+        S3Client s = AWSSDKClientUtils.newS3Client();
+        ResponseInputStream<GetObjectResponse> response
+                = s.getObject(GetObjectRequest.builder().bucket("mycamel").key("camel-content-type.txt").build());
+        assertEquals("application/text", response.response().contentType());
+    }
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
diff --git a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3SimpleUploadOperationIT.java b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3SimpleUploadOperationIT.java
index 536de40..b2e03db 100644
--- a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3SimpleUploadOperationIT.java
+++ b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3SimpleUploadOperationIT.java
@@ -88,7 +88,8 @@ public class S3SimpleUploadOperationIT extends Aws2S3Base {
         });
 
         S3Client s = AWSSDKClientUtils.newS3Client();
-        ResponseInputStream<GetObjectResponse> response = s.getObject(GetObjectRequest.builder().bucket("mycamel").key("camel-content-type.txt").build());
+        ResponseInputStream<GetObjectResponse> response
+                = s.getObject(GetObjectRequest.builder().bucket("mycamel").key("camel-content-type.txt").build());
         assertEquals("application/text", response.response().contentType());
     }
 

[camel] 02/03: CAMEL-17358 - AWS SDK2 Producer does not set the Content Type at all

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch camel-3.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 842cdf1d6d2f58b7fd38035a00246ad8d3547b2f
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jan 13 11:26:33 2022 +0100

    CAMEL-17358 - AWS SDK2 Producer does not set the Content Type at all
---
 .../s3/integration/S3SimpleUploadOperationIT.java  | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3SimpleUploadOperationIT.java b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3SimpleUploadOperationIT.java
index 3387868..536de40 100644
--- a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3SimpleUploadOperationIT.java
+++ b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3SimpleUploadOperationIT.java
@@ -26,7 +26,12 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.aws2.s3.AWS2S3Constants;
 import org.apache.camel.component.aws2.s3.AWS2S3Operations;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.infra.aws2.clients.AWSSDKClientUtils;
 import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.core.ResponseInputStream;
+import software.amazon.awssdk.services.s3.S3Client;
+import software.amazon.awssdk.services.s3.model.GetObjectRequest;
+import software.amazon.awssdk.services.s3.model.GetObjectResponse;
 import software.amazon.awssdk.services.s3.model.S3Object;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -68,6 +73,25 @@ public class S3SimpleUploadOperationIT extends Aws2S3Base {
         assertMockEndpointsSatisfied();
     }
 
+    @Test
+    public void sendInWithContentType() throws Exception {
+        result.expectedMessageCount(1);
+
+        template.send("direct:putObject", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(AWS2S3Constants.KEY, "camel-content-type.txt");
+                exchange.getIn().setHeader(AWS2S3Constants.CONTENT_TYPE, "application/text");
+                exchange.getIn().setBody("Camel rocks!");
+            }
+        });
+
+        S3Client s = AWSSDKClientUtils.newS3Client();
+        ResponseInputStream<GetObjectResponse> response = s.getObject(GetObjectRequest.builder().bucket("mycamel").key("camel-content-type.txt").build());
+        assertEquals("application/text", response.response().contentType());
+    }
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {

[camel] 01/03: CAMEL-17358 - AWS SDK2 Producer does not set the Content Type at all

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch camel-3.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit b7327d64169fb06eb0269af311bb3203a64674a7
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jan 13 11:05:56 2022 +0100

    CAMEL-17358 - AWS SDK2 Producer does not set the Content Type at all
---
 .../main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java
index 6412320..f5baf2b 100644
--- a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java
+++ b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java
@@ -317,6 +317,11 @@ public class AWS2S3Producer extends DefaultProducer {
             putObjectRequest.acl(objectAcl);
         }
 
+        String contentType = exchange.getIn().getHeader(AWS2S3Constants.CONTENT_TYPE, String.class);
+        if (contentType != null) {
+            putObjectRequest.contentType(contentType);
+        }
+
         BucketCannedACL acl = exchange.getIn().getHeader(AWS2S3Constants.ACL, BucketCannedACL.class);
         if (acl != null) {
             // note: if cannedacl and acl are both specified the last one will