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

0 votes
asked Jul 31 by lanopk (280 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)
break;
WriteToMyCustomCacheFile(buffer, len);
}
stream.Close();

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

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

Applies to: Rebex SFTP

1 Answer

+1 vote
answered Jul 31 by Lukas Matyska (37,860 points)
selected Aug 1 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 by lanopk (280 points)
Thank you very much.
...