Can support position,length parameters in the GetDownloadStream/GetUploadStream in the Sftp Client?

0 votes
asked Jul 31, 2017 by lanopk (1,620 points)

Rebex FTP client support location, length parameters in GetDownloadStream / GetUploadStream functions.
This is very useful for me.
Can SFTP clients support these parameters in GetDownloadStream / GetUploadStream?
Or please tell me what alternatives are available.

My ftp upload/download Codes are:

var stream = client.GetDownloadStream(path, position, length);
while(stream != null)
int len = stream.Read(buffer, 0, 8192);
if(len == 0)
WriteToMyCustomCacheFile(buffer, len);

var stream = client.GetUploadStream(path, position, length);
while(stream != null)
int len = ReadFromMyCustomFile(buffer, 8192);
if(len == 0)
stream.Write(buffer, 0, len);

PS : I can not found Rebex.IO.PIPE (Trial version).

Applies to: Rebex SFTP

1 Answer

+1 vote
answered Jul 31, 2017 by Lukas Matyska (61,230 points)
selected Aug 1, 2017 by lanopk
Best answer

The additional parameters are not necessary in SFTP.

Unlike FTP, the stream returned by SFTP is fully seekable. So, instead:

var stream = client.GetDownloadStream(path, position, offset);

you can do this:

var stream = client.GetDownloadStream(path);
stream.Seek(offset, position);
commented Jul 31, 2017 by lanopk (1,620 points)
Thank you very much.