You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/07/26 11:26:38 UTC

[camel] branch camel-3.18.x updated: CAMEL-18300: camel-google-storage - Content-Type and other headers should be stored via their specific setter than general metdata that leads to duplicate data in google cloud. (#8042)

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

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


The following commit(s) were added to refs/heads/camel-3.18.x by this push:
     new 1e91dfccfca CAMEL-18300: camel-google-storage - Content-Type and other headers should be stored via their specific setter than general metdata that leads to duplicate data in google cloud. (#8042)
1e91dfccfca is described below

commit 1e91dfccfca09d0a0c453228ac8aeb20f8447a07
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 26 13:26:02 2022 +0200

    CAMEL-18300: camel-google-storage - Content-Type and other headers should be stored via their specific setter than general metdata that leads to duplicate data in google cloud. (#8042)
---
 .../google/storage/GoogleCloudStorageProducer.java | 26 ++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/components/camel-google/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageProducer.java b/components/camel-google/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageProducer.java
index 845e9ec1079..71a3622312f 100644
--- a/components/camel-google/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageProducer.java
+++ b/components/camel-google/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageProducer.java
@@ -117,7 +117,29 @@ public class GoogleCloudStorageProducer extends DefaultProducer {
 
         Blob createdBlob;
         BlobId blobId = BlobId.of(bucketName, objectName);
-        BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setMetadata(objectMetadata).build();
+
+        BlobInfo.Builder builder = BlobInfo.newBuilder(blobId);
+        String ct = objectMetadata.remove("Content-Type");
+        if (ct != null) {
+            builder.setContentType(ct);
+        }
+        String cd = objectMetadata.remove("Content-Disposition");
+        if (cd != null) {
+            builder.setContentDisposition(ct);
+        }
+        String ce = objectMetadata.remove("Content-Encoding");
+        if (ce != null) {
+            builder.setContentEncoding(ct);
+        }
+        String md5 = objectMetadata.remove("Content-Md5");
+        if (md5 != null) {
+            builder.setMd5(md5);
+        }
+        String cc = objectMetadata.remove("Cache-Control");
+        if (cc != null) {
+            builder.setCacheControl(ct);
+        }
+        BlobInfo blobInfo = builder.setMetadata(objectMetadata).build();
         // According to documentation, this internally uses a WriteChannel
         createdBlob = storage.createFrom(blobInfo, is);
         LOG.trace("created createdBlob [{}]", createdBlob);
@@ -160,7 +182,7 @@ public class GoogleCloudStorageProducer extends DefaultProducer {
     }
 
     private Map<String, String> determineMetadata(final Exchange exchange) {
-        Map<String, String> objectMetadata = new HashMap<String, String>();
+        Map<String, String> objectMetadata = new HashMap<>();
 
         Long contentLength = exchange.getIn().getHeader(GoogleCloudStorageConstants.CONTENT_LENGTH, Long.class);
         if (contentLength != null) {