@@ -9406,6 +9406,7 @@ def download_file_from_ftp_file(url):
94069406 ftp .prot_p ()
94079407 # Try EPSV first, then fall back
94089408 try :
9409+ ftp .force_epsv = True
94099410 ftp .sendcmd ("EPSV" ) # request extended passive
94109411 ftp .retrlines ("LIST" , callback = lambda line : None )
94119412 except all_errors :
@@ -9416,7 +9417,10 @@ def download_file_from_ftp_file(url):
94169417 ftp .set_pasv (False )
94179418 ftp .retrlines ("LIST" , callback = lambda line : None )
94189419 ftpfile = MkTempFile ()
9419- ftp .retrbinary ("RETR " + urlparts .path , ftpfile .write )
9420+ if file_dir and file_dir not in ("/" , "" ):
9421+ ftp .cwd (file_dir )
9422+ ftp .retrbinary ("RETR " + file_name , ftpfile .write )
9423+ #ftp.retrbinary("RETR "+urlparts.path, ftpfile.write)
94209424 ftp .close ()
94219425 ftpfile .seek (0 , 0 )
94229426 return ftpfile
@@ -9480,6 +9484,7 @@ def upload_file_to_ftp_file(ftpfile, url):
94809484 ftp .prot_p ()
94819485 # Try EPSV first, then fall back
94829486 try :
9487+ ftp .force_epsv = True
94839488 ftp .sendcmd ("EPSV" ) # request extended passive
94849489 ftp .retrlines ("LIST" , callback = lambda line : None )
94859490 except all_errors :
@@ -9489,7 +9494,10 @@ def upload_file_to_ftp_file(ftpfile, url):
94899494 except all_errors :
94909495 ftp .set_pasv (False )
94919496 ftp .retrlines ("LIST" , callback = lambda line : None )
9492- ftp .storbinary ("STOR " + urlparts .path , ftpfile )
9497+ if file_dir and file_dir not in ("/" , "" ):
9498+ ftp .cwd (file_dir )
9499+ ftp .storbinary ("STOR " + file_name , ftpfile )
9500+ #ftp.storbinary("STOR "+urlparts.path, ftpfile)
94939501 ftp .close ()
94949502 ftpfile .seek (0 , 0 )
94959503 return ftpfile
0 commit comments