Hello, I am trying to use the sftp tools to upload a file using SFTP. using the same credentials I can upload a file using Filezilla. However, using wwSFTP I get an access denied. Note, I CAN connect and I CAN change directory via FtpSetDirectory, and I CAN get a list of files on the site via FtpListFiles. However, FtpSendFileEx fails with an -1 - Permission Denied. I am using client Tools v6.1
Sample:
loFtp = CREATEOBJECT("wwSftp")
loFtp.cFtpServer = lcFTPURL
loFtp.nFtpPort = 22
loFtp.cusername = lcFTPuser
loFtp.cPassword = lcFTPpwd
loFtp.ftpConnect() &&sucess
loFtp.FtpSetDirectory('inventory-files') &&success
loFiles = loFtp.FtpListFiles("") &&success
FOR EACH loFile IN loFiles FOXOBJECT
? loFile.Name
ENDFOR
lnResult = loFtp.FtpSendFileEx(paramFileName,paramFileName) &&fail. Permission denied.
Since I can upload via Filezilla using the same credentials I suspect I may be missing some setting in wwSFTP?
Am I eligible to upgrade to West Wind Client Tools 7? Would this make a difference?
Best regards and thank you! Robert.
Make sure your path name is correct for the upload. My guess is that you're perhaps not providing the path correctly. It should be in the form of:
relativeFolder/filename.ext
or /root/folder/filename.ext
.
Also if you're using relative folders, make sure you're in the folder you're expecting to be in.
+++ Rick ---
Rick, I hope you are well and healthy. Thanks for all the support over the years. You helped me out with this SFTP issue a while back and it has been working well. However, I recently started getting this error: "Object reference not set to an instance of an object"
loFtp = CREATEOBJECT("wwSftp")
loFtp.cFtpServer = lcFTPURL
loFtp.nFtpPort = 22
loFtp.cusername = lcFTPuser
loFtp.cPassword = lcFTPpwd
lnResult = loFtp.FtpSendFile(lcFTPURL,paramFileName,lcTargetFile,lcFTPuser,lcFTPpwd)
When I step through the logic of loFtp.FtpSendFile() The error is generated in wwsftp in the FtpSendFile Method:
llResult = this.oSFtp.UploadFileSimple(FULLPATH(lcSource),lcTarget,;
lcFtpServer,;
INT(this.nFtpPort),;
lcUsername, lcPassword)
The VFP debugger shows that oSFTP is an object. but i am not able to step into it or see properties on it. I suspect I got rid of a dependency or a Windows update replaced something... I am a bit at a loss. Can you provide any insight as to what it is trying to instantiate inside this UploadFileSimple method?
I have replaced all my latest runtime files for West-Wind: wwdotnetbridge.dll wwipstuff.dll renci.sshnet.dll etc. ( all the files from the wwClient 7.07 library )
Many thanks, Robert.
Sorry not sure beyond make sure that all the parameters have proper values. Make sure the server is a server name not a URL, and the paths are pointing at proper server resources...
There's an example in the Unit Tests in tests/wwsftptests.prg
that you can take a look at.
+++ Rick ---