0 votes
by (120 points)

I have huge files in the ftp server and want to open read stream mode to apply stream reader for the files, while reading the files another operation will be don't on that chunk of the stream and when the reader moving and seeking this should be handled by the SDK

Applies to: Rebex SFTP, Rebex FTP/SSL

1 Answer

0 votes
by (70.2k points)
edited by

There are two protocols FTP and SFTP. For differences see https://www.rebex.net/kb/secure-ftp/

  • SFTP protocol can provide seekable stream API. It is implemented by the Sftp.GetDownloadStream() method.

  • FTP protocol does not support seeking concept. It can be simulated (although inefficiently) if the server supports RANG extension, but the Rebex FTP API does not support it.
    If the server supports REST command and handles ABOR command correctly, you can use the Ftp.GetupDownloadStream(string remotePath, SeekOrigin origin, long offset) method to start download from specific position and when you want to seek close the download stream which will internally send ABOR command. Then request new download stream from desired position. If the server does not handle ABOR command correctly and hangs, you will have to reconnect the client.
    This is very ugly solution, but it is probably the only way how to do "seeking" in FTP protocol.