[Tutor] ftplib

Bob Gailer ramrom@earthling.net
Sat Feb 1 17:42:04 2003


--=======69DD463F=======
Content-Type: multipart/alternative; x-avg-checked=avg-ok-72668EC; boundary="=====================_14786622==.ALT"


--=====================_14786622==.ALT
Content-Type: text/plain; x-avg-checked=avg-ok-72668EC; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 8bit

At 05:13 PM 2/1/2003 -0500, Timothy M. Brauch wrote:

>I am trying to write a small python program that will login to an ftp server
>and put a file there.  I am using ftplib, and I have figured out how to log
>in (that was easy).  However, I cannot seem to figure out how to put a file.

Did you study the ftplib documentation in the Python Library reference? It 
offers:storbinary(command, file[, blocksize])
Store a file in binary transfer mode. command should be an appropriate 
"STOR" command: "STOR filename". file is an open file object which is read 
until EOF using its read() method in blocks of size blocksize to provide 
the data to be stored. The blocksize argument defaults to 8192. Changed in 
version 2.1: default for blocksize added.

storlines(command, file)
Store a file in ASCII transfer mode. command should be an appropriate 
"STOR" command (see storbinary()). Lines are read until EOF from the open 
file object file using its readline() method to provide the data to be stored.

Bob Gailer
mailto:ramrom@earthling.net
303 442 2625


--=====================_14786622==.ALT
Content-Type: text/html; x-avg-checked=avg-ok-72668EC; charset=us-ascii
Content-Transfer-Encoding: 8bit

<html>
<body>
At 05:13 PM 2/1/2003 -0500, Timothy M. Brauch wrote:<br><br>
<blockquote type=cite class=cite cite>I am trying to write a small python
program that will login to an ftp server<br>
and put a file there.&nbsp; I am using ftplib, and I have figured out how
to log<br>
in (that was easy).&nbsp; However, I cannot seem to figure out how to put
a file.</blockquote><br>
Did you study the ftplib documentation in the Python Library reference?
It offers:<tt><a name="l2h-2466"></a>storbinary</tt>(command,
file<font size=4>[</font>, blocksize<font size=4>]</font>) 
<dl>
<dd>Store a file in binary transfer mode. command should be an
appropriate &quot;<tt>STOR</tt>&quot; command: &quot;STOR filename&quot;.
file is an open file object which is read until EOF using its
<tt>read()</tt> method in blocks of size blocksize to provide the data to
be stored. The blocksize argument defaults to 8192. Changed in version
2.1: default for blocksize added. <br><br>

</dl><tt><a name="l2h-2467"></a>storlines</tt>(command, file) 
<dl>
<dd>Store a file in ASCII transfer mode. command should be an appropriate
&quot;<tt>STOR</tt>&quot; command (see <tt>storbinary()</tt>). Lines are
read until EOF from the open file object file using its
<tt>readline()</tt> method to provide the data to be
stored.<x-sigsep><p></x-sigsep>

</dl>Bob Gailer<br>
<a href="mailto:ramrom@earthling.net" eudora="autourl">mailto:ramrom@earthling.net</a><br>
303 442 2625<br>
</body>
</html>


--=====================_14786622==.ALT--

--=======69DD463F=======
Content-Type: text/plain; charset=us-ascii; x-avg=cert; x-avg-checked=avg-ok-72668EC
Content-Disposition: inline


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.445 / Virus Database: 250 - Release Date: 1/21/2003

--=======69DD463F=======--