GetUploadStream is a low level API and it would not be easily possible for us to modify line endings when uploading directly with this low-level approach. So the automatic line ending conversion in ASCII mode is only supported in Download, Upload, GetFile and PutFile methods.
However, if you need to take advantage of the automatic PutFile conversion, and at the same time use Stream for uploading, you could use Rebex experimental Pipe class like this:
Sftp sftp = new Sftp();
sftp.TransferType = SftpTransferType.Ascii;
// change this property and see if remoteFileContents contains either
// 'CRLF' sequence for newlines - in case of SftpServerType.Windows
// or 'LF' for newlines - in case of SftpServerType.Unix
sftp.ServerType = SftpServerType.Unix;
sftp.Connect("server");
sftp.Login("user", "password");
string remoteFile = "test0123.txt";
string textWithCRLF = "line1\r\nline2\r\nline3\r\nline4";
var ms = new MemoryStream(Encoding.ASCII.GetBytes(textWithCRLF));
ms.Position = 0;
using (var pipe = new Rebex.IO.Pipe())
{
var dst = pipe.Input;
var ar = sftp.BeginPutFile(pipe.Output, remoteFile, null, null);
var buffer = new byte[0x7000];
while (true)
{
int read = ms.Read(buffer, 0, buffer.Length);
if (read <= 0) break;
dst.Write(buffer, 0, read);
}
dst.Close();
long n = sftp.EndPutFile(ar);
}
// now download the file in binary mode and display it
sftp.TransferType = SftpTransferType.Binary;
ms = new MemoryStream();
sftp.GetFile(remoteFile, ms);
string remoteFileContents = Encoding.ASCII.GetString(ms.ToArray());
// display it so that CR and LF are visible
Console.WriteLine(remoteFileContents.Replace("\r", " {CR} ").Replace("\n", " {LF} "));
sftp.Disconnect();