How to FTP a ASCII file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tedpottel@gmail.com

    How to FTP a ASCII file

    Hi,

    My program has the following code to transfer a binary file

    f = open(pathanme+f ilename,'rb')
    print "start transfer"
    self.fthHandle. storbinary('STO R '+filename, f)

    How can I do an ASCII file transfer??????
    -Ted

  • John Machin

    #2
    Re: How to FTP a ASCII file

    On Jul 3, 9:02 am, "tedpot...@gmai l.com" <tedpot...@gmai l.comwrote:
    Hi,
    >
    My program has the following code to transfer a binary file
    >
    f = open(pathanme+f ilename,'rb')
    print "start transfer"
    self.fthHandle. storbinary('STO R '+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.
    """

    Comment

    • tedpottel@gmail.com

      #3
      Re: How to FTP a ASCII file

      On Jul 2, 7:12 pm, John Machin <sjmac...@lexic on.netwrote:
      On Jul 3, 9:02 am, "tedpot...@gmai l.com" <tedpot...@gmai l.comwrote:
      >
      Hi,
      >
      My program has the following code to transfer a binary file
      >
      f = open(pathanme+f ilename,'rb')
      print "start transfer"
      self.fthHandle. storbinary('STO R '+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

      Comment

      Working...