0 votes
by (2.0k points)

GetUploadStream() and Seek() doest not work.

Stream stream = GetUploadStream(path);
stream.Seek(0, SeekOrigin.Begin);

stream.Write(...);
stream.Write(...);
...

stream.Flush();
stream.Close();


Stream stream = GetUploadStream(path);
stream.Seek(1048576, , SeekOrigin.Begin);

stream.Write(...);
stream.Write(...);
...

stream.Flush();
stream.Close();

But uploaded file is broken.
if using your pipe or other methods, uploaded file is not broken.

I think GetUploadStream/GetDownloadStream is slow than using your pipe.
Can I get your advise for speed up using GetUploadStream/GetDownloadStream?

Thank you.

Applies to: Rebex SFTP

1 Answer

+1 vote
by (147k points)

1) We are currently not aware of any client-side bug in GetUploadStream/Seek and we are not able to reproduce the issue you describe. Would it be possible to provide a complete code that reproduces this issue, along with information about the SFTP/SSH server software?

2) Unlike GetFile/PutFile/Download/Upload methods, GetDownloadStream/GetUploadStream/GetStream don't use any buffering and are therefore slower. To work around this problem, the recommended workaround is to use the PutFile method with a Pipe helper class (although PutFileAsync should now be sued instead of BeginPutFile/EndPutFile.

by (2.0k points)
I sent my test source to support mail.
I get same result.
GetUploadStream and Seek failed. (file is not same)
but PutFileAsync with your pipe source is success. (file is same)
Thank you.
 (sorry my short english)
by (2.0k points)
My Test SFTP Server is Synology Nas DS218.
I did test with Ubuntu SSHD. and got same error.
by (147k points)
It looks like your test source has not reached us for some reason.
However, do you actually call GetUploadStream with the same path both times? This method actually truncates the file, which means that the result of your code above would be a file with 1048576 zeros followed by some data. If this is the case, please call GetStream(path, FileMode.OpenOrCreate, FileAccess.Write) instead of GetUploadStream(path). We'll clarify this in the documentation - sorry for the confusion!
by (2.0k points)
edited by
Okay.
GetStream works fine.
In this GetUploadStream and Seek case, I think that Seek function have to throw exception.
Thank you.
...