Reputation: 2507
How do I get apache camel to fetch multiple files using fileName
on the file component. Here is my route:
sftp://ftpserver:22/?username=blah&password=blah&stepwise=false&useList=false&ignoreFileNotFoundOrPermissionError=true&fileName=${file:onlyname.noext}.txt&delete=true&doneFileName=done")
The files that are on the ftp server are 1.txt
, 2.txt
, 3.txt
. How do I retrieve all of them without having to do a fixed fileName
such as fileName=3.txt
?
Upvotes: 0
Views: 3668
Reputation: 7636
Use the include
option such as:
include=.*\\.txt
include
uses Java regular expression.
Alternatively, you may use antInclude
:
antInclude=*.txt
EDIT:
antInclude
may contain more than one file name:
antInclude=1.txt,2.txt
(At least this works for local files.)
EDIT:
If you are not permitted to list on the FTP server, then you must setup a route for every single file:
for (int i = 0; i < 10; i++) {
from("sftp://ftpserver:22/?fileName=${file:onlyname.noext}."+i+".txt")
...;
}
However, depending on the the number of files, this is not really something I would like to do..
Upvotes: 1
Reputation: 13970
You can use the Simple expression language in the fileName
to provide a name pattern. There are some examples on the older documentation page http://camel.apache.org/file-language.html
In your case it should be sufficient to use fileName=*.txt
.
Upvotes: 1