How to FTP a ASCII file

John Machin sjmachin at lexicon.net
Mon Jul 2 19:12:18 EDT 2007


On Jul 3, 9:02 am, "tedpot... at gmail.com" <tedpot... at gmail.com> wrote:
> Hi,
>
> My program has the following code to transfer a binary file
>
>         f = open(pathanme+filename,'rb')
>         print "start transfer"
>         self.fthHandle.storbinary('STOR '+filename, f)
>
> How can I do an ASCII file transfer??????
> -Ted

I'm really curious as to how you could find out how to upload a file
in binary mode, but not in ASCII mode.

According to The Fantastic Manual:
"""
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.
"""




More information about the Python-list mailing list