resume upload

Jeff Epler jepler at
Tue Jul 5 14:21:26 EDT 2005

probably by using REST.  This stupid program puts a 200 line file by
sending 100 lines, then using REST to set a resume position and sending
the next 100 lines.

import getpass, StringIO, ftplib

lines = ["Line %d\n" % i for i in range(200)]
part1 = "".join(lines[:100])
part2 = "".join(lines[:100])

f = ftplib.FTP('server', 'username', 'password')
f.debugging = True
f.sendcmd('CWD /tmp')
f.storbinary("STOR example", StringIO.StringIO(part1))
f.putcmd('REST %d' % len(part1))
resp = f.getresp();
if resp[0] != '3': raise ftplib.error_reply, resp
f.storbinary("STOR example", StringIO.StringIO(part2))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <>

More information about the Python-list mailing list