Skip to content

Commit bf13665

Browse files
authored
Add files via upload
1 parent a2c14a0 commit bf13665

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

pyarchivefile.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9395,6 +9395,7 @@ def download_file_from_ftp_file(url):
93959395
ftp.prot_p()
93969396
# Try EPSV first, then fall back
93979397
try:
9398+
ftp.force_epsv = True
93989399
ftp.sendcmd("EPSV") # request extended passive
93999400
ftp.retrlines("LIST", callback=lambda line: None)
94009401
except all_errors:
@@ -9405,7 +9406,10 @@ def download_file_from_ftp_file(url):
94059406
ftp.set_pasv(False)
94069407
ftp.retrlines("LIST", callback=lambda line: None)
94079408
ftpfile = MkTempFile()
9408-
ftp.retrbinary("RETR "+urlparts.path, ftpfile.write)
9409+
if file_dir and file_dir not in ("/", ""):
9410+
ftp.cwd(file_dir)
9411+
ftp.retrbinary("RETR "+file_name, ftpfile.write)
9412+
#ftp.retrbinary("RETR "+urlparts.path, ftpfile.write)
94099413
ftp.close()
94109414
ftpfile.seek(0, 0)
94119415
return ftpfile
@@ -9469,6 +9473,7 @@ def upload_file_to_ftp_file(ftpfile, url):
94699473
ftp.prot_p()
94709474
# Try EPSV first, then fall back
94719475
try:
9476+
ftp.force_epsv = True
94729477
ftp.sendcmd("EPSV") # request extended passive
94739478
ftp.retrlines("LIST", callback=lambda line: None)
94749479
except all_errors:
@@ -9478,7 +9483,10 @@ def upload_file_to_ftp_file(ftpfile, url):
94789483
except all_errors:
94799484
ftp.set_pasv(False)
94809485
ftp.retrlines("LIST", callback=lambda line: None)
9481-
ftp.storbinary("STOR "+urlparts.path, ftpfile)
9486+
if file_dir and file_dir not in ("/", ""):
9487+
ftp.cwd(file_dir)
9488+
ftp.storbinary("STOR "+file_name, ftpfile)
9489+
#ftp.storbinary("STOR "+urlparts.path, ftpfile)
94829490
ftp.close()
94839491
ftpfile.seek(0, 0)
94849492
return ftpfile

0 commit comments

Comments
 (0)