O'Reilly logo

Mastering Spring Application Development by Anjana Mankale

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sending files over FTP using the Spring integration

Think of a scenario in which you are sending files over an FTP channel. Consider that there are two files, say Orders.txt and vendors.txt, that need to be sent over FTP to a remote location. To accomplish this, we need to follow these steps:

  1. Create FTPChannel.
  2. Make a directory in the base folder using baseFolder.mkdirs().
  3. Create two file objects at the base folder location.
  4. Use InputStream and create two separate streams for orders and vendors.
  5. Using the file utils available in Spring, copy the input streams to their specific files.
  6. Using the MessageBuilder class, use the withpayload() method to convert the files into messages.
  7. Lastly, send the message to the FTP channel and close the context.

Let's ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required