...
Name | Default Value | Description |
---|---|---|
directory | true | indicates whether or not the given file name should be interpreted by default as a directory or file (as it sometimes hard to be sure with some FTP servers) |
password | null | specifies the password to use to login to the remote file system |
binary | false | specifies the file transfer mode BINARY or ASCII. Default is ASCII. |
setNames | false | Used by FTPConsumer. If set to true Camel will set the special filename header FileComponent.HEADER_FILE_NAME value to the filename from the FTP Server. |
As this component is an extension to the File component the options from this parent component is also available.
...
When consuming files (downloading) you must use type conversation to either String or to InputStream for ASCII and BINARY file types.
We will improve this in Camel 1.4 so it hopefully works out-of-the-box.
Also in Camel 1.3 there is a issue that since setNames is default false then you must explicitly set the filename using the setHeader expression when consuming from FTP directly to File.
The code below illustrates this:
Code Block |
---|
private String ftpUrl = "ftp://camelrider@localhost:21/public/downloads?password=admin&binary=false"; private String fileUrl = "file:myfolder/?append=false&noop=true"; return new RouteBuilder() { public void configure() throws Exception { from(ftpUrl).setHeader(FileComponent.HEADER_FILE_NAME, constant("downloaded.txt")).convertBodyTo(String.class).to(fileUrl); } }; |
Or you can set the option to true as illustrated below:
Code Block |
---|
private String ftpUrl = "ftp://camelrider@localhost:21/public/downloads?password=admin&binary=false&setNames=true";
private String fileUrl = "file:myfolder/?append=false&noop=true";
return new RouteBuilder() {
public void configure() throws Exception {
from(ftpUrl).convertBodyTo(String.class).to(fileUrl);
}
};
|
...