Sftp_PutFile resultant file size is 32768 instead - WeOnlyDo Discussion board

Sftp_PutFile resultant file size is 32768 instead (General questions)

by Art, Thursday, September 27, 2007, 23:52 (6266 days ago)

I built my application with your demo DLL this morning. Got it all working. Then I purchased the real library and now when I SFTP a small 1016 byte text file, the resultant file is 32768 bytes of junk.

Any clues?

I am using blocking mode:

Here is the basic code:

bool SFTPPutFile(CWnd* pParentWnd, const char* pszFileFullPath, const char* pszLogin, const char* pszPassword, const char* pszDirectory, CString& strError)
{
UsiEnableDisable enableDisable(pParentWnd); // disables window input for scope because the SFTP library looks like it is doing a peek message loop

bool b = false;
strError.Empty();

// the original method of doing the SFTP supported username@hostname as the login
// but the WeOnlyDo SFTP library needs them seperated
CString strPassword = pszPassword;
CString strLogin = pszLogin; // username@hostname
CString strUsername, strHostname;
strUsername = strLogin.Left(strLogin.Find( @ ));
strHostname = strLogin.Mid(1 + strLogin.Find( @ ));

void* handle = Sftp_Create(NULL, NULL);
Sftp_SetBlocking(handle, 1);
Sftp_SetHostname(handle, strHostname.GetBuffer(strHostname.GetLength() + 1));
strHostname.ReleaseBuffer();
Sftp_SetLogin(handle, strUsername.GetBuffer(strUsername.GetLength() + 1));
strUsername.ReleaseBuffer();
Sftp_SetPassword(handle, strPassword.GetBuffer(strPassword.GetLength() + 1));
strPassword.ReleaseBuffer();
Sftp_SetPort(handle, 22);

int nConnect = Sftp_Connect(handle);
GetSFTPPutFileError(handle, nConnect, pszFileFullPath, pszLogin, pszDirectory, strError);
if (0 == nConnect)
{
CString strLocalFileFullPath = pszFileFullPath;
CString strRemote = pszDirectory;
strRemote += / ;
strRemote += strLocalFileFullPath.Mid(1 + strLocalFileFullPath.ReverseFind('\'));
int nPutFile = Sftp_PutFile(handle,
strLocalFileFullPath.GetBuffer(strLocalFileFullPath.GetLength() + 1),
strRemote.GetBuffer(strRemote.GetLength() + 1));
strLocalFileFullPath.ReleaseBuffer();
strRemote.ReleaseBuffer();

GetSFTPPutFileError(handle, nPutFile, pszFileFullPath, pszLogin, pszDirectory, strError);

if (0 == nPutFile)
b = true;

Sftp_Disconnect(handle);
}

Sftp_Destroy(handle);
handle = NULL;

return b;
}


Complete thread: