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

Author Message
ChirpingPanda
[View user's profile]

Joined: 2015-07-28
Posts: 2
Location: UK
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:

Code:

// 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?
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
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 http://winscp.net/eng/docs/rawsettings for Utf and PostLoginCommands.
ChirpingPanda
[View user's profile]

Joined: 2015-07-28
Posts: 2
Location: UK
prikryl 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 http://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
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
sessionOptions.AddRawSettings("Utf", "0");
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License