Problem downloading file from ftputil

I am trying to upload a file to my FTP server. Please advise what is wrong in the code below:

host: someserver.com

path: ./my_folder/at_this_server

target: 'test.pdf'

with ftputil.FTPHost(ftp_settings['host'],
                     ftp_settings['user'],
                     ftp_settings['password'],
                     ftp_settings['port']) as ftp_host:
    safe_chdir(ftp_host, ftp_settings['path']) # change FTP dir
    ftp_host.upload_if_newer('local_test.pdf', 'test.pdf')

      

The upload_if_newer()

or command succeeds upload()

, but I don't see the uploaded file in the FTP folder.

UPDATE

I found that the file is only loaded in host+"/my_folder"

instead of host+"/my_folder/at_this_server"

.

+3


source to share


1 answer


1) Check the result ftp_host.upload_if_newer('local_test.pdf', 'test.pdf')

. If it is True

, then the file has been copied.
2) Are you sure the function is safe_chdir

correct? You can check if the current directory has changed to FTP with ftp_host.getcwd()

. Try uploading the file using the full path instead of changing the FTP directory.
3) Check access rights.



+2


source







All Articles