This is an automated email from the ASF dual-hosted git repository.
oscerd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
The following commit(s) were added to refs/heads/main by this push:
new 957fd47de Fix #2952: enforce that the file/ce-file header is a file
name in the file-transfer sinks (#2966)
957fd47de is described below
commit 957fd47ded3aecdd692f8d7d3f29194cc746c386
Author: Andrea Cosentino <[email protected]>
AuthorDate: Tue Aug 25 08:39:26 2026 +0200
Fix #2952: enforce that the file/ce-file header is a file name in the
file-transfer sinks (#2966)
* Fix #2952: reduce the file/ce-file header to a single file name in the
file-transfer sinks
ftp-sink, ftps-sink, sftp-sink and azure-storage-files-sink copied the
inbound file / ce-file header into CamelFileName verbatim, so a value
carrying path separators resolved relative to the configured directoryName
instead of staying inside it.
Reduce the header to its last path segment and discard a dots-only value,
so the file is always written inside the configured directory. Document the
contract in all four doc partials; sftp-sink had no Optional Headers
section at all.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
* Fix #2952: use the built-in file:onlyname language instead of an inline
regex
Address review feedback: replace the replaceAll chain in the four
file-transfer sinks with Camel's file language, which exists for exactly
this job and keeps the regex out of the Kamelet spec.
The normalisation stays inside each choice branch. Applying it after the
choice would set CamelFileName to an empty value when neither file nor
ce-file was supplied, which is not the same as leaving it unset and would
break the default naming convention.
Verified end to end through a Kamelet template: file=../../etc/evil.txt
writes evil.txt inside the configured directory, ce-file=sub/dir/report.csv
writes report.csv, and no header still yields the exchange-id name.
file:onlyname leaves a bare ".." unchanged where the old regex blanked it.
That names the parent directory rather than traversing into it and is
rejected by the file and FTP producers, so the trade is worth the
readability.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
---------
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
---
.../ROOT/partials/azure-storage-files-sink-description.adoc | 5 +++++
docs/modules/ROOT/partials/ftp-sink-description.adoc | 6 +++++-
docs/modules/ROOT/partials/ftps-sink-description.adoc | 6 +++++-
docs/modules/ROOT/partials/sftp-sink-description.adoc | 12 +++++++++++-
kamelets/azure-storage-files-sink.kamelet.yaml | 6 ++++++
kamelets/ftp-sink.kamelet.yaml | 6 ++++++
kamelets/ftps-sink.kamelet.yaml | 6 ++++++
kamelets/sftp-sink.kamelet.yaml | 6 ++++++
8 files changed, 50 insertions(+), 3 deletions(-)
diff --git
a/docs/modules/ROOT/partials/azure-storage-files-sink-description.adoc
b/docs/modules/ROOT/partials/azure-storage-files-sink-description.adoc
index c37764792..b11f38c74 100644
--- a/docs/modules/ROOT/partials/azure-storage-files-sink-description.adoc
+++ b/docs/modules/ROOT/partials/azure-storage-files-sink-description.adoc
@@ -24,3 +24,8 @@ For more information, see the
https://learn.microsoft.com/en-us/java/api/overvie
=== Optional Headers
In the headers, you can set the `file` / `ce-file` property to specify the
filename to upload. If you do set property in the header, the Kamelet uses the
exchange ID as filename.
+
+The value is reduced to a single file name before use: any directory component
is
+dropped, so `reports/2026/data.csv` is stored as `data.csv`. The file is always
+written inside the configured directory.
+
diff --git a/docs/modules/ROOT/partials/ftp-sink-description.adoc
b/docs/modules/ROOT/partials/ftp-sink-description.adoc
index ba08ab0a5..03cf0d3f8 100644
--- a/docs/modules/ROOT/partials/ftp-sink-description.adoc
+++ b/docs/modules/ROOT/partials/ftp-sink-description.adoc
@@ -23,4 +23,8 @@ Requires:
In the header, you can optionally set the `file` / `ce-file` property to
specify the name of the file to upload.
-If you do not set the property in the header, the Kamelet uses a default
naming convention.
\ No newline at end of file
+If you do not set the property in the header, the Kamelet uses a default
naming convention.
+
+The value is reduced to a single file name before use: any directory component
is
+dropped, so `reports/2026/data.csv` is stored as `data.csv`. The file is always
+written inside the configured directory.
diff --git a/docs/modules/ROOT/partials/ftps-sink-description.adoc
b/docs/modules/ROOT/partials/ftps-sink-description.adoc
index 329847679..bf6fa1466 100644
--- a/docs/modules/ROOT/partials/ftps-sink-description.adoc
+++ b/docs/modules/ROOT/partials/ftps-sink-description.adoc
@@ -27,4 +27,8 @@ Requires:
In the header, you can optionally set the `file` / `ce-file` property to
specify the name of the file to upload.
-If you do not set the property in the header, the Kamelet uses a default
naming convention.
\ No newline at end of file
+If you do not set the property in the header, the Kamelet uses a default
naming convention.
+
+The value is reduced to a single file name before use: any directory component
is
+dropped, so `reports/2026/data.csv` is stored as `data.csv`. The file is always
+written inside the configured directory.
diff --git a/docs/modules/ROOT/partials/sftp-sink-description.adoc
b/docs/modules/ROOT/partials/sftp-sink-description.adoc
index 4b35b2a97..f4663a969 100644
--- a/docs/modules/ROOT/partials/sftp-sink-description.adoc
+++ b/docs/modules/ROOT/partials/sftp-sink-description.adoc
@@ -32,4 +32,14 @@ SFTP supports file transfer resume capabilities, allowing
interrupted transfers
=== Cross-Platform Compatibility
-Works seamlessly across different operating systems and platforms, providing
consistent secure file transfer capabilities in heterogeneous environments.
\ No newline at end of file
+Works seamlessly across different operating systems and platforms, providing
consistent secure file transfer capabilities in heterogeneous environments.
+
+=== Optional Headers
+
+In the header, you can optionally set the `file` / `ce-file` property to
specify the name of the file to upload.
+
+If you do not set the property in the header, the Kamelet uses a default
naming convention.
+
+The value is reduced to a single file name before use: any directory component
is
+dropped, so `reports/2026/data.csv` is stored as `data.csv`. The file is always
+written inside the configured directory.
diff --git a/kamelets/azure-storage-files-sink.kamelet.yaml
b/kamelets/azure-storage-files-sink.kamelet.yaml
index d54c88298..216f42156 100644
--- a/kamelets/azure-storage-files-sink.kamelet.yaml
+++ b/kamelets/azure-storage-files-sink.kamelet.yaml
@@ -80,11 +80,17 @@ spec:
- setHeader:
name: CamelFileName
simple: "${header[file]}"
+ - setHeader:
+ name: CamelFileName
+ simple: "${file:onlyname}"
- simple: "${header[ce-file]}"
steps:
- setHeader:
name: CamelFileName
simple: "${header[ce-file]}"
+ - setHeader:
+ name: CamelFileName
+ simple: "${file:onlyname}"
otherwise:
steps:
- setHeader:
diff --git a/kamelets/ftp-sink.kamelet.yaml b/kamelets/ftp-sink.kamelet.yaml
index 671a2f54a..c57053150 100644
--- a/kamelets/ftp-sink.kamelet.yaml
+++ b/kamelets/ftp-sink.kamelet.yaml
@@ -101,11 +101,17 @@ spec:
- setHeader:
name: CamelFileName
simple: "${header[file]}"
+ - setHeader:
+ name: CamelFileName
+ simple: "${file:onlyname}"
- simple: "${header[ce-file]}"
steps:
- setHeader:
name: CamelFileName
simple: "${header[ce-file]}"
+ - setHeader:
+ name: CamelFileName
+ simple: "${file:onlyname}"
- to:
uri:
"ftp:{{username}}@{{connectionHost}}:{{connectionPort}}/{{directoryName}}"
parameters:
diff --git a/kamelets/ftps-sink.kamelet.yaml b/kamelets/ftps-sink.kamelet.yaml
index 533ff54ca..f55d67864 100644
--- a/kamelets/ftps-sink.kamelet.yaml
+++ b/kamelets/ftps-sink.kamelet.yaml
@@ -101,11 +101,17 @@ spec:
- setHeader:
name: CamelFileName
simple: "${header[file]}"
+ - setHeader:
+ name: CamelFileName
+ simple: "${file:onlyname}"
- simple: "${header[ce-file]}"
steps:
- setHeader:
name: CamelFileName
simple: "${header[ce-file]}"
+ - setHeader:
+ name: CamelFileName
+ simple: "${file:onlyname}"
- to:
uri:
"ftps:{{username}}@{{connectionHost}}:{{connectionPort}}/{{directoryName}}"
parameters:
diff --git a/kamelets/sftp-sink.kamelet.yaml b/kamelets/sftp-sink.kamelet.yaml
index adededd24..44f16d7fe 100644
--- a/kamelets/sftp-sink.kamelet.yaml
+++ b/kamelets/sftp-sink.kamelet.yaml
@@ -135,11 +135,17 @@ spec:
- setHeader:
name: CamelFileName
simple: "${header[file]}"
+ - setHeader:
+ name: CamelFileName
+ simple: "${file:onlyname}"
- simple: "${header[ce-file]}"
steps:
- setHeader:
name: CamelFileName
simple: "${header[ce-file]}"
+ - setHeader:
+ name: CamelFileName
+ simple: "${file:onlyname}"
- to:
uri: "sftp:{{connectionHost}}:{{connectionPort}}/{{directoryName}}"
parameters: