Python Forum
ftplib and pyftpdlib : REST (restart) command not working as expected when uploading
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ftplib and pyftpdlib : REST (restart) command not working as expected when uploading
#3
I guess i made a silly mistake. In case someone else encounters the same, i had to add myfile.seek(rest_pos,0)
in Client code # 2 to start reading the file at the specific position. So it should look like this:


import ftplib

ftp = ftplib.FTP()
ftp.connect("localhost",8080)
ftp.login("test","123")

block_size = 128
c_dir = "C:\\Users\\Usr\\Desktop\\client_data"
filename = "test.pdf" # ~ 30Mb

ftp.dir()
myfile = open(c_dir + "\\" + filename , "rb")

ftp.voidcmd('TYPE I')
rest_pos = ftp.size(filename)
print(rest_pos)

myfile.seek(rest_pos,0)

ftp.storbinary("STOR " + filename, myfile, blocksize=block_size, rest=rest_pos)

ftp.dir()
ftp.close()
storbinary() takes care of the conversion of rest_pos from int to str
Reply


Messages In This Thread
RE: ftplib and pyftpdlib : REST (restart) command not working as expected when uploading - by darellon - Mar-05-2017, 12:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to restart another PC on the local network? Kundan 1 2,164 Sep-21-2019, 11:31 AM
Last Post: ThomasL
  ftplib os.listdir function peterkl 1 4,630 Jun-07-2019, 08:21 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020