I am new to Python 3, I have a question here.., Using Python libraries/modules like Paramiko
I was able to login into SFTP Server successfully. I want to copy / upload a file from Local server directory to specified SFTP server directory.
I was able to do it successfuly for one particular file, i.e., I was able to copy / upload a particular file from Local path to SFTP server path.
But , my question is how do I copy / upload all files in a particular Local directory to target SFTP server directory , in one go ?
Which Python library / module is good d for this task ?
Below is the code which I have developed :
So here in the below python code, I could upload only a single file from local path to the SFTP target path successfully , but how do I upload all files in a particular local path to the desired SFTP target path ? I need to do this in one go.
import paramiko
import os
SFTP_Server_Host = axdjuorjdf@ujt.com
SFTP_UserName = fbhipy
SFTP_Password = xxxxxxxxx
sftp_ssh = paramiko.SSHClient()
sftp_ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
sftp_ssh.connect(hostname=SFTP_Server_Host ,username=SFTP_UserName ,password=SFTP_Password)
sftp_check = sftp_ssh.open_sftp()
print("Connected to SFTP server : " +SFTP_Server_Host)
print()
print("Username of SFTP server : " +SFTP_UserName)
print()
sftp_check.chdir('dev/sample/user/test_data')
sftp_check.mkdir('app_data')
sftp_check.put('C:\\Prod_data\\Sample_prod.csv','dev/sample/user/test_data/app_data/Sample_prod.csv')
print("File transfered to SFTP Server : " +SFTP_Server_Host)
print()
--> Here instead of mentioning a particular file name , how could I upload all files from 'C:\Prod_data\' to 'dev/sample/user/test_data/app_data/'? <--