I am using Apache Camel File2 (SFTP) (with Camel Latest version) and Java8 API. I am trying to develop a MyRouteBuilder.java class which extends RouteBuilder class and implements the configure method.
I want to transfer files from source path to destination path. Here in the source endpoint, specifying the URI parameter "include" to include files from particular specific subfolders under the source path like "SubFolder1, SubFolder2, SubFolder3".
Example Source URIs: 1) "file:\src\SubFolder1\.*\.txt" 2) "file:\src\SubFolder2\.*\.txt"
I have tried with the multiple examples below and even Examples:
1) include=.SubFolder[1-2]\.*\.txt
2) include=.SubFolder1|SubFolder2\.*\.txt
3) include=SubFolder[1-2]\.*\.txt
4) include=SubFolder1\.*\.txt
5) include=.SubFolder(?)\.*\.txt
Nothing is working.
Please suggest a way to solve using Apache Camel File2 API using Java.
public void configure() throws Exception {
String sftpUrl = "sftp://" + user + "@" + hostName + sourcePath + "?" + "noop=true"
+ "&recursive=true&include=.*\\.txt$"+"&strictHostKeyChecking=no" + "&useUserKnownHostsFile=true" + "&password=RAW("
+ password + ")&preferredAuthentications=publickey,keyboard-interactive,password";
System.out.println("\n\n sftpUrl + " + sftpUrl + "\n\n");
from(sftpUrl)
.log(" Copying File : ${file:name} ").process(exchange -> {
System.out.println("1. Processing a File --> = " + exchange);
}).to("file://" + destPath)
// ;
.log("Uploading file ${file:parent} / ${file:name} complete.");
}
include
. Please post your whole route in the question not here in comments. - ShellDragon