resume upload

J

Jeff Epler

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))
f.quit()

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFCys+lJd01MZaTXX0RAll+AJ4nGsvlUSox7mT9PzOLg8tofHv+qACfXByv
Ukjo6xtGnmt2AsrcNc9cOj8=
=PgIS
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top