I am trying to transfer a file from linux server to a directory which is Lambda. I am using Paramiko module. I am passing a directory like '/temp/upload/'

IsADirectoryError: [Errno 21] Is a directory: '/home/mmoradi2/data/' but it says as below in the cloud watch log.

[ERROR] IsADirectoryError: [Errno 21] Is a directory: '/tmp/upload/'

I have no idea what is the problem. This is my code:

    import paramiko
    import pysftp

    cnopts = pysftp.CnOpts()
    cnopts.hostkeys = None
    with pysftp.Connection(host=host, username=user, password=password, port=22, cnopts=cnopts) as sftp:
    
        sftp.chdir(ftp_filepath)              
        for file in filesList:
             sftp_remote_path = (ftp_filepath + file)
             sftp.get(sftp_remote_path, localpath = '/temp/upload', preserve_mtime = True) 

I was able to make the connection and successfully changed the directory using sftp.chdir(ftp_filepath) but I am getting Is a directory: '/home/mmoradi2/data/' error!

Can someone please help me to understand why it's failing

I have tried using get_d() also but getting same error!

0

There are 0 answers