다음 스크립트를 사용하여 SFTP 서버에 zip 파일을 업로드하고 있습니다. 서버에서 파일을 볼 수는 있지만 항상 0 Kb임을 보여줍니다.chilkat python을 사용하여 SFTP 서버에 zip 파일 업로드
#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