-
Oct 29th, 2008, 02:05 PM
#1
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 :-)
-
Oct 30th, 2008, 02:05 PM
#2
You're best off waiting a bit for Ftp support. Keep an eye out for the Spring Extenstions project dedicated to Spring Integration Adapters.
-
Nov 4th, 2008, 11:53 AM
#3
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;
}
}
-
Nov 4th, 2008, 12:39 PM
#4
Thanks
Thanks a lot pgangi, I will try to do with your example. :-)
-
Nov 4th, 2008, 01:26 PM
#5
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
-
Forum Rules