javasftpjsch

Resume file transfer for a halfway failed file transfer with JSch


I am using this JSch library (http://www.jcraft.com/jsch/) in my ColdFusion application. My application wants to implement a retry mechanism - if a file transfer fails halfway through then I want to resume (or continue) the file transfer from where it left off. Is this possible to achieve using this JSch library?


Solution

  • Just reconnect and start an upload again with RESUME flag:

    channelSftp.put(src, dst, ChannelSftp.RESUME);
    

    The RESUME flag will make JSch query size of a partial remote file and restart the transfer from there. If the file is already uploaded completely, it transfers nothing.