Question

I’m refactoring a Java EE application that uses apache commons net FTP library to facilitate FTP transfers between two servers. The code is almost identical to the code posted as an example on the web page, http://commons.apache.org/proper/commons-net/examples/ftp/ServerToServerFTP.java. The files that are being transferred sometimes exceed 60 gb, and even though the timeout is set quite high, and the largest transfers are over a LAN, I’m still seeing some exceptions.

I’ve been trying to figure out how to implement the REST function in FTP, i.e. resume of transfers. The servers support it so it only needs to be implemented using commons. So far I’ve gathered that I need to use getRestartOffset and setRestartOffset. I have not been able to locate any resources or examples online of how this can be implemented in a server-to-server transfer and was wondering whether anybody has any pointers or examples?

Edit: Solution Using the solution suggested by user270349 I was able to implement the desired functionality, although it was not possible by using the REST command. I got the amount of bytes written from the destination, set the offset on both destination and source and then used the remoteAppend(String filename) method provided by the library instead of remoteStore(String filename) which is used in the example linked above.

Was it helpful?

Solution

The only difference between Server->Client download resume and Server->Server transfer resume is how you get the restarOffset. You need to list the files in the destination directory (remote in your case) and use the partial file size as offset for the next attempt.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top