The FTP Outbound Gateway provides a limited set of commands to interact with a remote FTP/FTPS
server.
Commands supported are:
• ls (list files)
• get (retrieve file(s))
• rm (remove file(s))
ls supports the following options:
• -1 - just retrieve a list of filenames, default is to retrieve a list of FileInfo objects.
• -a - include all files (including those starting with '.')
• -f - do not sort the list
• -dirs - include directories (excluded by default)
• -links - include symbolic links (excluded by default)
In addition, filename filtering is provided, in the same manner as the inbound-channel-adapter.
The message payload resulting from an ls operation is a list of file names, or a list of FileInfo objects.
These objects provide information such as modified time, permissions etc.
The remote directory that the ls command acted on is provided in the file_remoteDirectory
header.
get supports the following option:
• -P - preserve the timestamp of the remote file
The message payload resulting from a get operation is a File object representing the retrieved file.
The remote directory is provided in the file_remoteDirectory header, and the filename is
provided in the file_remoteFile header.
The rm command has no options.
Note: Filters are not supported with the rm command.
The message payload resulting from an rm operation is Boolean.TRUE if the remove was successful,
Boolean.FALSE otherwise. The remote directory is provided in the file_remoteDirectory
header, and the filename is provided in the file_remoteFile header.
In each case, the PATH that these commands act on is provided by the 'expression' property of the
gateway.
Here is an example of a gateway configured for an ls command...
Code:
<int-ftp:outbound-gateway id="gateway1"
session-factory="ftpSessionFactory"
request-channel="inbound1"
command="ls"
command-options="-1"
expression="payload"
reply-channel="toSplitter"/>
The payload of the message sent to the toSplitter channel is a list of String objects containing the filename
of each file. If the command-options was omitted, it would be a list of FileInfo objects. Options
are provided space-delimited, e.g. command-options="-1 -dirs -links".