How to FTP a ASCII file

T

tedpottel

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
 
A

Adonis Vargas

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

Taken from online documentation:

http://docs.python.org/lib/ftp-objects.html

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.

Hope this helps.

Adonis
 
J

John Machin

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.
"""
 
T

tedpottel

Taken from online documentation:

http://docs.python.org/lib/ftp-objects.html

storlines(command, file)

Store a file inASCIItransfer 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.

Hope this helps.

Adonis

Thank you it waqs soooo simple, works fine now!!!!
 
T

tedpottel

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 anASCIIfile transfer??????
-Ted

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

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 inASCIItransfer 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.
"""

Hi,
I did a google on python file transfer and got links to sample code
using a binary transfer, but thier was no links to sample code using
ascc. Thank you for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,433
Messages
2,571,683
Members
48,796
Latest member
Greg L.

Latest Threads

Top