GetUploadStream method, unlike
PutFile, was not optimised for speed.
When you call upload-stream's
Write method, Rebex SFTP sends a single SSH_FXP_WRITE command to the server, waits for response, and only then it returns. On the other hand,
PutFile initially sends multiple SSH_FXP_WRITE commands without waiting for server reply and when each reply is received, subsequent SSH_FXP_WRITE is sent, keeping the link saturated.
If you need a writable upload stream with PutFile-like speed, use
BeginPutFile method with our experimental Pipe class:
src.Position = 0;
using (var pipe = new Rebex.IO.Pipe())
var dst = pipe.Input;
var ar = client.BeginPutFile(pipe.Output, remoteFile, null, null);
var buffer = new byte[0x7000];
int read = src.Read(buffer, 0, buffer.Length);
if (read <= 0) break;
dst.Write(buffer, 0, read);
long n = client.EndPutFile(ar);
// [test #4, duration ... 00:00:??.??]
Please let me know whether this works!