Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

wildview

Re: OverwriteMode.Append using PutFile on an SFTP server, doesn't appear to work

Hi Martin, thanks for the 6.2 beta update. The PutFile stream now works to append data. Thanks so much!
wildview

Re: OverwriteMode.Append using PutFile on an SFTP server, doesn't appear to work

Awesome, thanks for taking the time to add it in. It'll be nice to have that feature in there. I didn't notice in the doc that the streamed PutFile didn't support it. I use most of the functionality of this pkg for SFTP use and everything else works great. Thanks again!
wildview

Re: OverwriteMode.Append using PutFile on an SFTP server, doesn't appear to work

Awesome thanks.
martin

Re: OverwriteMode.Append using PutFile on an SFTP server, doesn't appear to work

Thanks for your report. Indeed, it does not seem to work. I'll look into it.
wildview

OverwriteMode.Append using PutFile on an SFTP server, doesn't appear to work

Hi, I'm using the WinSCP PutFile programmatically in C# to stream byte data to our SFTP server to create files and using the overwrite mode it works great. However, after the file is created and exists, all subsequent PutFile calls w/ the TransferOptions.Overwrite = OverwriteMode.Append still just overwrite the file. I thought WinSCP using an SFTP server was suppose to support appending data to existing files if using the OverwriteMode.Append mode, is that correct? Can someone help me resolve this problem?

I extracted some code out of our build just to show how the PutFile is being called without the sessionOptions, maybe this will help to shed some light on why the append doesn't work.

Thanks so much!
sessionOptions = new SessionOptions{...}
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
transferOptions.OverwriteMode = OverwriteMode.Append;
 
String data = "Hello World\n";   
byte[] byteArray = Encoding.ASCII.GetBytes(data);
using (MemoryStream stream = new MemoryStream(byteArray))
{
  using (Session session = new Session())
  {
    session.Open(sessionOptions);
    session.PutFile(stream, "/sftpuser/test/test.txt", transferOptions);
  }
}