How To Upload File Using Python Module Pysftp

 

 

def upload_file(filename,uploadDir,host_conf=[]):

    srv = pysftp.Connection(host=host_conf[0], username=host_conf[1],password=host_conf[2])
    srv.chdir(uploadDir)
    srv.put(filename)
    srv.close()

 

upload_file("test.txt","/home/mydirectory",["hostname","username","password"] )

 

email@djangotutsme.com June 9, 2016, 3:49 a.m.