Reputation: 910
Is it possible to read a file from an FTP message source and send it straight to a channel as a Message<String> with the file contents as the message payload and the filename in a header? How would I do this?
Right now, it is writing the file from the FTP source to disk, which I don't want it to do. I'd then have to read off of the disk and then convert it into a message or write a file source of some sort. I want it to go straight from the FTP source directly into the channel as a Message<String>.
To explain the situation, I am having multiple FTP sources all polling into a channel as one flow. I am then wanting all messages in that channel to go to a JdbcOutboundGateway to write the messages to a DB table in another flow. However, when it gets into the channel from the FTP source, the message payload ends up just being the file path. I want the FTP message source to not create a file, just a Message<String> and place into the channel.
Upvotes: 2
Views: 801
Reputation: 5420
Did you check FTP Streaming Inbound Channel Adapter documentation?
The streaming inbound channel adapter was introduced in version 4.3. This adapter produces message with payloads of type
InputStream
, allowing files to be fetched without writing to the local file system.
I think this is exactly what you want. You end up with Message<InputStream>
in your channel, but you always can transform these into Message<String>
using message transformers, like StreamTransformer.
Upvotes: 3