We need to send a test file to a customer via SFTP.
We are using the PutFile method which returns the correct number of bytes transferred (28) and does not throw an exception except the file is never transferred. The test file does not exist in the remote directory and does not appear when searching over sftp via the GetItems method.
This logic has worked for numerous customers but is now failing for this one.
using (var client = new Rebex.Net.Sftp())
{
client.LogWriter = new Rebex.ConsoleLogWriter(Rebex.LogLevel.Debug);
client.Connect("*****.***.*****.com", 2032);
client.Login("*********", "*******");
const string testFileName = "test.txt";
const string testFileContent = "File upload test successful.";
const string ReceiveDirectory = "Receive";
var remoteFilePath = Path.Combine(ReceiveDirectory, testFileName).Replace("\\", "/");
var bytes = Encoding.Default.GetBytes(testFileContent);
using (var stream = new MemoryStream(bytes))
{
var bytesTransferred = client.PutFile(stream, remoteFilePath);
// value = 28
bytesTransferred.Dump();
}
// value = false
client.FileExists(remoteFilePath).Dump();
}
Logs:
2017-08-15 09:57:29.525 DEBUG Sftp(31)[16] SSH: Authentication successful.
2017-08-15 09:57:29.694 DEBUG Sftp(31)[16] SSH: Requesting subsystem 'sftp'.
2017-08-15 09:57:29.863 INFO Sftp(31)[16] Command: SSH_FXP_INIT (4)
2017-08-15 09:57:30.031 INFO Sftp(31)[16] Response: SSH_FXP_VERSION (3, 1 extension)
2017-08-15 09:57:30.031 INFO Sftp(31)[16] Info: Using SFTP v3.
2017-08-15 09:57:30.032 INFO Sftp(31)[16] Command: SSH_FXP_REALPATH (1, '.')
2017-08-15 09:57:30.206 INFO Sftp(31)[16] Response: SSH_FXP_NAME (1, 1 item)
2017-08-15 09:57:30.206 INFO Sftp(31)[16] Info: Current directory is '/'.
2017-08-15 09:57:30.206 INFO Sftp(31)[16] Command: SSH_FXP_OPEN (2, '/Receive/test.txt', 26)
2017-08-15 09:57:30.480 INFO Sftp(31)[16] Response: SSH_FXP_HANDLE (2, 0x30)
2017-08-15 09:57:30.480 DEBUG Sftp(31)[16] Command: SSH_FXP_WRITE (3, 0x30, 0, 28 bytes)
2017-08-15 09:57:30.653 DEBUG Sftp(31)[16] Response: SSH_FXP_STATUS (3, 0, 'The write completed successfully')
2017-08-15 09:57:30.653 INFO Sftp(31)[16] Command: SSH_FXP_CLOSE (4, 0x30)
2017-08-15 09:57:30.911 INFO Sftp(31)[16] Response: SSH_FXP_STATUS (4, 0, 'The operation completed')
28 // dumped out by linq pad
2017-08-15 09:57:30.913 INFO Sftp(31)[16] Command: SSH_FXP_STAT (5, '/Receive/test.txt')
2017-08-15 09:57:31.159 INFO Sftp(31)[16] Response: SSH_FXP_STATUS (5, 2, 'The message [/Receive/test.txt] is not extractable!')
False //dumped out by linq pad
Thanks in advance for any help figuring this out.