Results 1 to 5 of 5

Thread: FTPTarget Help

  1. #1
    Join Date
    Oct 2008
    Location
    Santa Fe, Argentina
    Posts
    11

    Default FTPTarget Help

    Hi, I'm very new in spring.
    I need to send a file to a ftp server with Spring Integration.

    I have sucess to retrieve files from FTP Server doing the following in my configuration file:

    ...
    <channel-adapter id="channelInput" source="fileFTP">
    <poller period="60000"/>
    </channel-adapter>
    <ftp-source id="fileFTP"
    host="localhost"
    port="21"
    username="cristian"
    password="123"
    local-working-directory="${java.io.tmpdir}/output"
    remote-working-directory="/"/>
    ....

    Like I said before, now I need to send file. How can I do that. Please, if you can send my and example.

    Thanks a lot and sorry my english. I speak spanish :-)

  2. #2
    Join Date
    May 2007
    Location
    Netherlands
    Posts
    614

    Default

    You're best off waiting a bit for Ftp support. Keep an eye out for the Spring Extenstions project dedicated to Spring Integration Adapters.

  3. #3

    Default An example

    public class CartrkFileDownloadClient {

    private final Logger logger = LoggerFactory.getLogger(
    CartrkFileDownloadClient.class);

    private QueuedFTPClientPool cartrkFtpClientPool;

    /**
    * Set method for cartrkFtpClientPool
    * @param cartrkFtpClientPool Ftp client pool
    */
    public void setCartrkFtpClientPool(QueuedFTPClientPool cartrkFtpClientPool) {
    this.cartrkFtpClientPool = cartrkFtpClientPool;
    }

    /**
    * Retrieves the specified file if it exists in the specified directory
    * @param fileName file which need to be downloaded
    * @return ByteArrayOutputStream Byte Array Output stream if file is found
    * else returns null
    */
    public ByteArrayOutputStream retrieveFile(String fileName) {

    logger.debug("Looking for a remote file", fileName);
    FTPClient ftpClient = null;
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    try {
    ftpClient = cartrkFtpClientPool.getClient();

    if (!ftpClient.retrieveFile(fileName, outputStream)) {

    return null;
    }

    } catch (Exception exception) {
    logger.error("Exception occurred while downloading CARTRK file", exception);
    }
    return outputStream;
    }
    }

  4. #4
    Join Date
    Oct 2008
    Location
    Santa Fe, Argentina
    Posts
    11

    Default Thanks

    Thanks a lot pgangi, I will try to do with your example. :-)

  5. #5
    Join Date
    May 2007
    Location
    Netherlands
    Posts
    614

    Default

    guys, you can go for the extensions project now http://www.springsource.org/extensions/se-sia.

    I would recommend using the FtpFileSource in combination with an inbound channel adapter. This synchronized the local working directory with the remote directory over ftp. The local directory is read by a FileReadingMessageSource, so you can use the built in transformers there.

    I did a substantial refactoring yesterday, so you might find some issues.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •