This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new c59936a9e824 CAMEL-22925: Enhance S3 producer to stream the payload of
type GenericFile (#21109)
c59936a9e824 is described below
commit c59936a9e82476633f65fd693a9de0231d5a7142
Author: Bartosz Popiela <[email protected]>
AuthorDate: Thu Jan 29 07:21:33 2026 +0100
CAMEL-22925: Enhance S3 producer to stream the payload of type GenericFile
(#21109)
* Enhance S3 producer to stream the payload of type GenericFile
* Add getFileLength to WrappedFile
* Replace instance-of cast with pattern matching
---
.../java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java | 5 +++--
core/camel-api/src/main/java/org/apache/camel/WrappedFile.java | 6 ++++++
2 files changed, 9 insertions(+), 2 deletions(-)
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 ac20947dd14e..2603723906de 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
@@ -324,8 +324,9 @@ public class AWS2S3Producer extends DefaultProducer {
try {
// Need to check if the message body is WrappedFile
- if (obj instanceof WrappedFile) {
- obj = ((WrappedFile<?>) obj).getFile();
+ if (obj instanceof WrappedFile<?> wrappedFile) {
+ contentLength = wrappedFile.getFileLength();
+ obj = wrappedFile.getFile();
}
if (obj instanceof File) {
// optimize for file payload
diff --git a/core/camel-api/src/main/java/org/apache/camel/WrappedFile.java
b/core/camel-api/src/main/java/org/apache/camel/WrappedFile.java
index e6980d121a15..c2916fc85c94 100644
--- a/core/camel-api/src/main/java/org/apache/camel/WrappedFile.java
+++ b/core/camel-api/src/main/java/org/apache/camel/WrappedFile.java
@@ -35,4 +35,10 @@ public interface WrappedFile<T> {
*/
Object getBody();
+ /**
+ * Gets the file length in bytes.
+ *
+ * @return the length of the file in bytes.
+ */
+ long getFileLength();
}