0
我正在使用以下脚本在SFTP服务器上上传zip文件。虽然我看到服务器上的文件,但它始终显示它的0 KB使用chilkat将zip文件上载到SFTP服务器python
#Code to upload file to a SFTP server abc.com
import chilkat
sftp = chilkat.CkSFtp()
success = sftp.UnlockComponent("Anything trial")
puttyKey = chilkat.CkSshKey()
ppkText = puttyKey.loadText("xyz.ppk")
success = puttyKey.FromPuttyPrivateKey(ppkText)
sshHostname = "abc.com"
sshPort = 22
success = sftp.Connect(sshHostname,sshPort)
sftp.AuthenticatePwPk("username", "password", puttyKey)
success = sftp.InitializeSftp()
filename = "file.zip"
handle = sftp.openFile(filename ,"writeOnly","createTruncate")
success = sftp.UploadFile(handle,"file.zip")
success = sftp.CloseHandle(handle)
另外..传递给OpenFile的文件名是要在服务器上创建的文件名。传递给UploadFile的文件路径是本地文件路径。 – Matt