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?