Post a reply

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

martin

Re: C# FTP Upload Server Requires OPTS 'off' - WinSCP.SessionRemoteException: Error transferring file

sessionOptions.AddRawSettings("Utf", "0");
ChirpingPanda

Re: C# FTP Upload Server Requires OPTS 'off' - WinSCP.SessionRemoteException: Error transferring file

martin wrote:

Do you mean OPTS UTF8 ON/OFF? Do you explicitly need to send OPTS UTF8 OFF or just avoid WinSCP sending OPTS UTF8 ON?

See https://winscp.net/eng/docs/rawsettings for Utf and PostLoginCommands.


Hi prikryl, is it possible to avoid sending the OPTS command? If so, how?

Thanks.
martin

Re: C# FTP Upload Server Requires OPTS 'off' - WinSCP.SessionRemoteException: Error transferring file

Do you mean OPTS UTF8 ON/OFF? Do you explicitly need to send OPTS UTF8 OFF or just avoid WinSCP sending OPTS UTF8 ON?

See https://winscp.net/eng/docs/rawsettings for Utf and PostLoginCommands.
ChirpingPanda

C# FTP Upload Server Requires OPTS 'off' - WinSCP.SessionRemoteException: Error transferring file

I am receiving the following exception and inner exception when attempting to upload an image to a server.

WinSCP.SessionRemoteException: Error transferring file 'c:\data\test.png'

Inner exception: WinSCP.SessionRemoteException: Copying files to remote side failed.

How my application interacts with the WinSCP library:

// Setup session options

SessionOptions sessionOptions = new SessionOptions
{
    Protocol = Protocol.Ftp,
    HostName = this.Uri.Host,
    UserName = this.Credentials.UserName,
    Password = this.Credentials.Password,
    TimeoutInMilliseconds =300000,
};

var localFilePath = @"c:\data\test.png";
var remoteDir = @"/home/";

using (WinSCP.Session session = new WinSCP.Session())
{
    // Connect
    session.Open(sessionOptions);

    // Upload files
    TransferOptions transferOptions = new TransferOptions();
    transferOptions.TransferMode = TransferMode.Ascii;

    TransferOperationResult transferResult;
    transferResult = session.PutFiles(localFilePath, remoteDir, false, transferOptions);


    // Throw on any error
    transferResult.Check();

    // Print results
    foreach (TransferEventArgs transfer in transferResult.Transfers)
    {
   Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
    }
}


I have a hunch that because the server I am uploading to requires OPTS to be off (doesn't accept data in UTF8 and I have no way of changing it as other projects depend upon this setting being off) it is struggling to accept the file being uploaded. Is there any way to achieve turning OPTS off?