Skip to content

Commit 0a386ea

Browse files
authored
Add files via upload
1 parent 03e8349 commit 0a386ea

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

pycatfile.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9407,6 +9407,7 @@ def download_file_from_ftp_file(url):
94079407
ftp.prot_p()
94089408
# Try EPSV first, then fall back
94099409
try:
9410+
ftp.force_epsv = True
94109411
ftp.sendcmd("EPSV") # request extended passive
94119412
ftp.retrlines("LIST", callback=lambda line: None)
94129413
except all_errors:
@@ -9417,7 +9418,10 @@ def download_file_from_ftp_file(url):
94179418
ftp.set_pasv(False)
94189419
ftp.retrlines("LIST", callback=lambda line: None)
94199420
ftpfile = MkTempFile()
9420-
ftp.retrbinary("RETR "+urlparts.path, ftpfile.write)
9421+
if file_dir and file_dir not in ("/", ""):
9422+
ftp.cwd(file_dir)
9423+
ftp.retrbinary("RETR "+file_name, ftpfile.write)
9424+
#ftp.retrbinary("RETR "+urlparts.path, ftpfile.write)
94219425
ftp.close()
94229426
ftpfile.seek(0, 0)
94239427
return ftpfile
@@ -9481,6 +9485,7 @@ def upload_file_to_ftp_file(ftpfile, url):
94819485
ftp.prot_p()
94829486
# Try EPSV first, then fall back
94839487
try:
9488+
ftp.force_epsv = True
94849489
ftp.sendcmd("EPSV") # request extended passive
94859490
ftp.retrlines("LIST", callback=lambda line: None)
94869491
except all_errors:
@@ -9490,7 +9495,10 @@ def upload_file_to_ftp_file(ftpfile, url):
94909495
except all_errors:
94919496
ftp.set_pasv(False)
94929497
ftp.retrlines("LIST", callback=lambda line: None)
9493-
ftp.storbinary("STOR "+urlparts.path, ftpfile)
9498+
if file_dir and file_dir not in ("/", ""):
9499+
ftp.cwd(file_dir)
9500+
ftp.storbinary("STOR "+file_name, ftpfile)
9501+
#ftp.storbinary("STOR "+urlparts.path, ftpfile)
94949502
ftp.close()
94959503
ftpfile.seek(0, 0)
94969504
return ftpfile

0 commit comments

Comments
 (0)