次のスクリプトを使用してSFTPサーバーにzipファイルをアップロードしています。サーバー上のファイルは表示されますが、常に0 KBと表示されます。chilkat pythonを使用してzipファイルをSFTPサーバーにアップロード
#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