Hi all, all. To upload a file in an FTLS I used the FTP_TLS from ftplib, here is my code (I adapted from a code found on the web):
import ftplib from ftplib import FTP_TLS import os import ssl import sys server = XXXXXXXXXXXXX user = XXXXXXXXXXXXXXXX passwd = XXXXX PathFile = 'Q:\GW\EC1140WH_Con_HF\HCM_CARTS' def connect_ftp(): ftp = FTP_TLS(server, user, passwd) ftp.set_pasv(True) ftp.prot_p() ftp.set_debuglevel(2) return ftp def upload_file(ftp_connection, upload_file_path): try: upload_file1 = open(os.path.join(PathFile,upload_file_path), 'r') print('Uploading ' + upload_file_path + "...") ftp_connection.storbinary('STOR ' + upload_file_path, upload_file1) ftp_connection.quit() ftp_connection.close() upload_file.close() print('Upload finished.') except Exception, e: print("Error uploading file: " + str(e)) ftp_conn = connect_ftp() if ftp_conn: print("Success connection") upload_file(ftp_conn, 'LisezmoiReadme.docx')
Unfortunatly, I got the message:
Success connection
Uploading LisezmoiReadme.docx...
*cmd* 'TYPE I' *put* 'TYPE I\r\n'
*get* '200 Type set to I.\r\n'
*resp* '200 Type set to I.'
*cmd* 'PASV' *put* 'PASV\r\n'
*get* '227 Entering Passive Mode (142,34,138,110,197,108).\r\n'
*resp* '227 Entering Passive Mode (142,34,138,110,197,108).'
*cmd* 'STOR LisezmoiReadme.docx'
*put* 'STOR LisezmoiReadme.docx\r\n'
*get* '125 Data connection already open; Transfer starting.\r\n'
*resp* '125 Data connection already open; Transfer starting.'
*get* '425 Data channel timed out due to not meeting the minimum bandwidth requirement.\r\n'
*resp* '425 Data channel timed out due to not meeting the minimum bandwidth requirement.'
Error uploading file: 425 Data channel timed out due to not meeting the minimum bandwidth requirement.
The last line is the error and i dont know how to resolve it? Any help please? Is it better to use the transfercmd command?
I use ArcGIS 10.1
Thanks a lot
Solved! Go to Solution.
Hi all I resolve the problem
Here is the code
import ftplib from ftplib import FTP_TLS import os import sys server = XXXXXXXX user = XXXXXXXXXXX passwd = XXXXXXXXXXXXXX PathFile = 'XXXXXXXXXXXXXXXXXXXXXX def connect_ftp(): ftp = ftplib.FTP_TLS(timeout=10) ftp.connect(server, 21) ftp.auth() ftp.prot_p() ftp.login(user, passwd) ftp.set_debuglevel(2) return ftp def upload_file(ftp_connection, upload_file_path): try: upload_file1 = open(os.path.join(PathFile,upload_file_path), 'r') print('Uploading ' + upload_file_path + "...") ftp_connection.storbinary('STOR ' + upload_file_path, upload_file1, 1000) ftp_connection.quit() ftp_connection.close() upload_file1.close() print('Upload finished.') except Exception, e: print("Error uploading file: " + str(e)) ftp_conn = connect_ftp() if ftp_conn: print("Success connection") upload_file(ftp_conn, 'LisezmoiReadme.docx')
Thanks
could you format the code block using syntax highlighting please
This doesn't appear to have anything to do with ArcGIS. You might be better asking this question at StackOverflow
The point Luke is making is that is a computing skill and not a GIS skill per se, perhaps it is presumed erroneously that one has the former before one applies them to the latter.
Hi all I resolve the problem
Here is the code
import ftplib from ftplib import FTP_TLS import os import sys server = XXXXXXXX user = XXXXXXXXXXX passwd = XXXXXXXXXXXXXX PathFile = 'XXXXXXXXXXXXXXXXXXXXXX def connect_ftp(): ftp = ftplib.FTP_TLS(timeout=10) ftp.connect(server, 21) ftp.auth() ftp.prot_p() ftp.login(user, passwd) ftp.set_debuglevel(2) return ftp def upload_file(ftp_connection, upload_file_path): try: upload_file1 = open(os.path.join(PathFile,upload_file_path), 'r') print('Uploading ' + upload_file_path + "...") ftp_connection.storbinary('STOR ' + upload_file_path, upload_file1, 1000) ftp_connection.quit() ftp_connection.close() upload_file1.close() print('Upload finished.') except Exception, e: print("Error uploading file: " + str(e)) ftp_conn = connect_ftp() if ftp_conn: print("Success connection") upload_file(ftp_conn, 'LisezmoiReadme.docx')
Thanks
Hi Said,
Although it is while ago, how about if some one want to download .csv file from FTPS with "Require explicit FTP over TLS".
I can download manually my.csv file in filezilla with the same protocol but unfortunately whenever I tried this in python timeout error coming up while accessing any LIST or DIR command from python ftplib. I am not sure what is going on? Any idea?