Upload file to SFTP using python

你离开我真会死。 提交于 2019-12-08 07:57:54

问题


I'm trying to upload file to SFTP server from my local directory. Here is my code

import paramiko
import pysftp

hostname = 'host'
username='user'
password='password'
port=port
source = 'c:/test.csv'
destination = '/home/local'
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname=hostname,port=port,username=username,password=password)
ftp_client=client.open_sftp()
ftp_client.put(source,destination)
ftp_client.close()

I'm getting an IOError

here is my Error. Please let me know where the error is


回答1:


Using the .put() method, the remotepath should include the filename, see documentation at http://docs.paramiko.org/en/2.4/api/sftp.html#paramiko.sftp_client.SFTPClient.put



来源:https://stackoverflow.com/questions/50632535/upload-file-to-sftp-using-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!