ftplib only posting 52 bytes?

David Bolen db3l at fitlinxx.com
Thu Jun 14 01:12:41 EDT 2001


Brent Stroh <bmstroh at cavtel.net> writes:

> Today, I added the FTP step, figuring it would save me a few minutes to
> kick the transfer off in the background.  It appears the first 52 bytes of
> each image is transferred to the server; what is sent appears to be the
> beginning of a JPG file.

One thought is that you're not opening the file in binary for the
transfer.  Although you're using a binary store store operation at the
FTP level, that only notifies the server to process the incoming
stream without conversion.  The FTP module is still reading the file
through your text mode file object, and probably stopping at what it
thinks is an EOF when it sees the first ^Z (ASCII 26) in the file.

E.g.:

> def send_file(filename):
> 	ftp = FTP('server', 'user', 'pass')
> 	ftp.set_pasv(0)
> 	ftp.cwd('/home/bmstroh/public_html/images')
> 	print dest + filename
> 	fp = open(dest + filename)

Try changing this to: fp = open(dest+filename,'rb')

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list