8

I am using the below Python code to upload a file via SFTP using Paramiko. The connection "seems" to be fine, the code executes to the end, just the file isn't reaching the destination when I check in FileZilla.

I have checked and set permissions on the file to 777 (just to be sure). I have also checked my file path string in a separate terminal and the path is valid.

import paramiko
.
.

transport = paramiko.Transport((host, port))
transport.connect(username = username, password = password)
sftp = paramiko.SFTPClient.from_transport(transport)

sftp.put(filePath, "/")  # Upload file to root FTP folder
sftp.close()
transport.close()

What can I do to debug this? Anything I can print out, check connection succeeded etc?

0

1 Answer 1

16

The second argument of SFTPClient.put (remotepath) is path to a file, not a folder:

the destination path on the SFTP server. Note that the filename should be included. Only specifying a directory may result in an error.

Try this:

sftp.put(filePath, "/filename")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.