[Pythonmac-SIG] blocksize problem? (ftplib)
JoanCarles p Casasín
joanca@typerware.com
Wed, 1 Mar 2000 16:56:40 +0100
Hi you all,
I'm trying to upload an html file to a remote server via FTP.
It works pretty well (thanks to Erik, mainly :) but I've only a little
problem. The file, once is in the server is cut. Some of the last lines
are lost (including the closing tag </html>).
Here's the script.
import ftplib
serveraddress = 'www.xxx.com'
ftp = ftplib.FTP(serveraddress)
ftp.login('xxx', 'xxx') # or ftp.login() if you're anonymous
print ftp.getwelcome()
ftp.cwd("//grrr")
#the path to the local file you want to transfer
path = outputf_path
f = open(path, 'rb')
#print f.read() gives you the whole document data,
# so the problem should be below.
# the name the document should have on the server
docname = 'default.html'
#Erik guessed maybe has to do with the block size
#I've also tried 512, 2048 and 4096 and still missing
#something, different each time.
ftp.storbinary('STOR '+ docname, f, 1024)
f.close()
ftp.close()
Thanks,
JoanCarles
:::!!!:::
joanca@typerware.com
http://www.typerware.com