2

I am new to Spring and I am currently working on spring integration with ftp support.

  • I made a transfer from local directory to a server(filZilla).
  • I downloaded the file from server and it was fine.

But I want to find how I can Transfer file from FTP Server to another FTP Server and if it's possible to read file without downloading it from the server.

PatJ
  • 5,996
  • 1
  • 31
  • 37
Ahmed
  • 23
  • 3

2 Answers2

1

If you mean fetch a file and send it to another server without writing it to the local file system then, no, that's not currently possible with standard components.

However, you can use two FtpRemoteFileTemplates (use the execute method) to stream the data from an InputStream to an OutputStream.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
0
FtpRemoteFileTemplate server1;
FtpRemoteFileTemplate server2
server1.get("filetotransfer", new InputStreamCallback() {
    @Override
    public void doWithInputStream(final InputStream stream) throws IOException {
        server2.executeWithClient(new ClientCallback<FTPClient, Void>() {
            @Override
            public Void doWithClient(final FTPClient client) {
               try (final OutputStream outStream = client.storeFileStream("filedestination");) {
                   IOUtils.copyLarge(stream, outputStream)
               }
        }
    }
});
steviemo
  • 104
  • 6