...
Info | ||
---|---|---|
| ||
Absolute path is not supported. Camel 2.16 will translate absolute path paths to relative ones by trimming all leading slashes from |
...
Where directoryname represents the underlying directory. The directory name is a relative path. Absolute path's is paths are not supported. The relative path can contain nested folders, such as /inbox/us.
...
Info | ||
---|---|---|
| ||
When using the When using |
...
The option readLock can be used to force Camel not to consume files that is are currently in the progress of being written. However, this option is turned off by default, as it requires that the user has write access. See the options table at File2 for more details about read locks.
There are other solutions to avoid consuming files that are currently being written over FTP; for instance, you can write to a temporary destination and move the file after it has been written.
...
The two set of libraries (see top) has have different API APIs for setting timeout. You can use the connectTimeout
option for both of them to set a timeout in millis to establish a network connection. An individual soTimeout
can also be set on the FTP/FTPS, which corresponds to using ftpClient.soTimeout
. Notice SFTP will automatically use connectTimeout
as its soTimeout
. The timeout
option only applies for FTP/FTSP as the data timeout, which corresponds to the ftpClient.dataTimeout
value. All timeout values are in millis.
...
Camel supports pluggable filtering strategies. This strategy it to use the build in can be provided by implementing org.apache.camel.component.file.GenericFileFilter
in Java. You can then configure the endpoint with such a filter to skip certain filters before being processed.
...
When you want to download a single file and knows know the file name, you can use fileName=myFileName.txt
to tell Camel the name of the file to download. By default the consumer will still do a FTP LIST command to do a directory listing and then filter these files based on the fileName
option. Though in this use-case it may be desirable to turn off the directory listing by setting useList=false
. For example the user account used to login to the FTP server may not have permission to do a FTP LIST command. So you can turn off this with useList=false
, and then provide the fixed name of the file to download with fileName=myFileName.txt
, then the FTP consumer can still download the file. If the file for some reason does not exist, then Camel will by default throw an exception, you can turn this off and ignore this by setting ignoreFileNotFoundOrPermissionError=true
.
For example to have a Camel route that pickup picks up a single file, and delete deletes it after use you can dowrite
Code Block |
---|
from("ftp://admin@localhost:21/nolist/?password=admin&stepwise=false&useList=false&ignoreFileNotFoundOrPermissionError=true&fileName=report.txt&delete=true") .to("activemq:queue:report"); |
Notice that we have use used all the options we talked above above.
You can also use this with ConsumerTemplate
. For example to download a single file (if it exists) and grab the file content as a String type:
...