Reputation: 5139
Using Java DSL, I have a route in which I poll a file in an SFTP server using the file name set in the message headers
from("direct:download")
.pollEnrich()
.simple("sftp://my.host:22/folder/?username=foo&fileName=${header.CamelFileName}")
.to("file://state/downloaded");
The sftp endpoint needs to have set a private key. Usually something like this suffices:
endpoint("sftp://my.host:22/folder/?username=foo&fileName=my_file_explicitly_written_here", SftpEndpoint.class).getConfiguration().setPrivateKey(getSshPrivateKey());
However, I see no way to "mix" dynamic fields in the URI (${header.CamelFileName}
) in the pollEnrich().simple()
) with endpoint configuration.
Any suggestion on this?
Upvotes: 0
Views: 2186
Reputation: 4919
You can reference privateKey
as bean from registry.
.pollEnrich()
.simple("sftp://my.host:22/folder/?username=foo&privateKey=#myKeyInRegistry&fileName=${header.CamelFileName}")
Binding bean to registry depends on platform and Camel version you are using.
Upvotes: 3