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 2019/07/02 08:21:32 UTC
[camel] 01/04: CAMEL-13714 - Camel-AWS-S3: Add and option to
specify the S3 Key also as endpoint parameter
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 4db25713dca73f3c321af0aeb076acd88f529256
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Jul 2 09:17:04 2019 +0200
CAMEL-13714 - Camel-AWS-S3: Add and option to specify the S3 Key also as endpoint parameter
---
.../apache/camel/component/aws/s3/S3Configuration.java | 15 ++++++++++++++-
.../org/apache/camel/component/aws/s3/S3Producer.java | 5 ++++-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/components/camel-aws-s3/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java b/components/camel-aws-s3/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java
index b43f64e..3cd8efc 100644
--- a/components/camel-aws-s3/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java
+++ b/components/camel-aws-s3/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java
@@ -90,6 +90,8 @@ public class S3Configuration implements Cloneable {
private String awsKMSKeyId;
@UriParam(defaultValue = "false")
private boolean useIAMCredentials;
+ @UriParam(label = "producer")
+ private String keyName;
public long getPartSize() {
return partSize;
@@ -475,7 +477,18 @@ public class S3Configuration implements Cloneable {
this.autoCreateBucket = autoCreateBucket;
}
- public boolean hasProxyConfiguration() {
+ public String getKeyName() {
+ return keyName;
+ }
+
+ /**
+ * Setting the key name for an element in the bucket through endpoint parameter
+ */
+ public void setKeyName(String keyName) {
+ this.keyName = keyName;
+ }
+
+ public boolean hasProxyConfiguration() {
return ObjectHelper.isNotEmpty(getProxyHost()) && ObjectHelper.isNotEmpty(getProxyPort());
}
diff --git a/components/camel-aws-s3/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java b/components/camel-aws-s3/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java
index ce4b8c5..84621b6 100644
--- a/components/camel-aws-s3/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java
+++ b/components/camel-aws-s3/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java
@@ -471,8 +471,11 @@ public class S3Producer extends DefaultProducer {
private String determineKey(final Exchange exchange) {
String key = exchange.getIn().getHeader(S3Constants.KEY, String.class);
+ if (ObjectHelper.isEmpty(key)) {
+ key = getConfiguration().getKeyName();
+ }
if (key == null) {
- throw new IllegalArgumentException("AWS S3 Key header missing.");
+ throw new IllegalArgumentException("AWS S3 Key header missing.");
}
return key;
}