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:53:29 UTC

[camel] branch camel-3.11.x updated (a7e8b44 -> 1eedd64)

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

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


    from a7e8b44  CAMEL-17471 - Snakeyaml: Use safe constructor where the default one has been used
     new c0e8f4b  CAMEL-17358 - AWS SDK2 Producer does not set the Content Type at all
     new d89552e  CAMEL-17358 - AWS SDK2 Producer does not set the Content Type at all
     new 1eedd64  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] 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.11.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit c0e8f4b20a8343b6774108b8710bafe3a672b8ea
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 117aea1..d537dba 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
@@ -296,6 +296,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

[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.11.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit d89552e75a3d5d01bcaf9cb74abed34b898d2e05
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] 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.11.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 1eedd64594fbf34d854cad17954a8a9dd95e9a36
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 d537dba..d20805e 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
@@ -176,6 +176,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());
     }