[Tutor] ftp file size puzle

Pijus Virketis virketis@post.harvard.edu
Wed, 26 Jun 2002 20:36:36 +0300


<HTML><HEAD>
<BASEFONT FACE=3D"Arial" SIZE=3D"2" COLOR=3D"#000000">
</HEAD>
<BODY>
<div>Dear all, </div>
<div>&nbsp;</div>
<div>I am running into an FTP problem. Basically, I am just=
 trying to work out the very basics of ftplib, and store a file=
 on a server running on my own machine. Here's an example of a=
 typical session, with the problem at the end.</div>
<div>&nbsp;</div>
<div>&gt;&gt;&gt; from ftplib import FTP</div>
<div>&gt;&gt;&gt; ftp =3D FTP(&quot;localhost&quot;)</div>
<div>&gt;&gt;&gt; ftp.login(&quot;foo&quot;,=
 &quot;password&quot;)</div>
<div>'230 User logged in.'</div>
<div>&gt;&gt;&gt; ftp.cwd(&quot;upload&quot;)</div>
<div>'250 &quot;/upload&quot; is current directory.'</div>
<div>&gt;&gt;&gt; file =3D open(&quot;foo.pdf&quot;)</div>
<div>&gt;&gt;&gt; ftp.storbinary(&quot;STOR foo.pdf&quot;, file,=
 8192)</div>
<div>'226 Transfer complete. 1200 bytes in 0 sec. (0.00=
 Kb/s).'</div>
<div>&nbsp;</div>
<div>Right, so I get an &quot;all OK&quot; message. Except that=
 the foo.pdf file is actually 500KB big, not 1KB! This has been=
 hounding me for a while now, I have tried varying the buffer=
 size and the files I am sending. The file is indeed placed in=
 the ftp root directory, but it is always a fraction of the size=
 of the real thing: not much good at all, unfortunately. I am=
 using Windows XP, Python 2.2.1 and GuildFTP as my server. But I=
 am sure this has little to do with the tools, and much to do=
 with some glaring error I make in my ignorance. I am pretty sure=
 I have set all the permissions correctly, because I can use a=
 proper FTP client with the same account to upload any file=
 successfully. </div>
<div>&nbsp;</div>
<div>Thanks for all help, </div>
<div>&nbsp;</div>
<div>Pijus </div>
<div>&nbsp;</div>
<div>-- </div>
<div>&quot;Anyone attempting to generate random numbers by=
 deterministic means is, of course, living in a state of=
 sin.&quot; -- John Von Neumann</div>
</body></html>