0 votes
by (180 points)
edited

I want to download multiple files in parallel over SFTP, so if there is a large file that is started downloading first and a 2nd small download is started the 2nd download should not be held up by the 1st.

I can think of several ways to do this, but can't figure out which ones will work (or indeed if there is a better solution).

  1. One instance of Sftp and lots of calls to GetFileAsync
  2. One instance of Sftp and lots of Tasks (or threads) calling into it calling GetFile.
  3. Lots of Tasks all creating an instance of Sftp with a call to GetFile

Will any/all of these approaches work?

What is the recommended way of achieving what I want?

If you call sftp.Disconnect() does it abort all current transfers?

Applies to: Rebex SFTP

1 Answer

+1 vote
by (148k points)
edited
 
Best answer

All these approaches will work and the 1st one (one instance of Sftp and lots of calls to GetFileAsync) is recommended. The 2nd approach is OK as well.

Calling sftp.Disconnect() will abort all current transfers. Calling sftp.AbortTransfer(null) will do it as well without disconnecting.

(Please note that this only applies to Rebex SFTP. With Rebex FTP/SSL - Ftp object - only the 3rd approach would work because the FTP protocol doesn't support multiple simultaneous transfer over a single session.)

...