java - Schedule remote file download over FTP and process file in memory with Spring Integration -



java - Schedule remote file download over FTP and process file in memory with Spring Integration -

i need download file remote ftp server every day , provide contents class inputstream (or @ to the lowest degree byte[]) farther processing. ideally should avoid disk write.

can give advice on how configure xml or annotation based configuration?

spring integration doesn't have pre-configured adapter 'stream' file; does, however, have underlying component (ftpremotefiletemplate) enables such access.

you can configure remote file template bean (using xml or java config) - giving session mill etc, , invoke 1 of get() methods:

/** * retrieve remote file inputstream. * * @param remotepath remote path file. * @param callback callback. * @return true if operation successful. */ boolean get(string remotepath, inputstreamcallback callback); /** * retrieve remote file inputstream, based on info in message. * * @param message message evaluated generate remote path. * @param callback callback. * @return true if operation successful. */ boolean get(message<?> message, inputstreamcallback callback);

something this...

final bytearrayoutputstream baos = new bytearrayoutputstream(); boolean success = template.get("foo.txt", new inputstreamcallback() { @override public void dowithinputstream(inputstream stream) throws ioexception { filecopyutils.copy(stream, baos); } }); if (success) { byte[] bytes = baos.tobytearray()); ... }

or can pass input stream straight handler in dowithinputstream().

the ftpremotefiletemplate added in spring integration 3.0 (but get() variant takes string rather message<?> added in 4.0).

sftpremotefiletemplate available.

java spring ftp spring-integration

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -