Fastest way to read images from SSH server in python

Viewed 37

My goal is to read images from the SSH server and then upload them to Mongodb. Uploading part works fine, but reading each image takes about 10seconds. I am wondering if there is a faster analog of this code.

ssh = paramiko.SSHClient()
ssh.load_system_host_keys()
ssh.connect(hostname=hostname, username=username)
sftp = ssh.open_sftp()

for image in sftp.listdir_iter(directory):
    with sftp.open(directory + image.filename) as f:
        image = f.read()
    upload(image)
0 Answers
Related