1. Home
  2. Computing & Technology
  3. Python

Building an FTP Client in Python

From , former About.com Guide

6 of 6

FTP Storage and Retrieval in Binary Mode

The binary methods of ftplib have similar syntax:

    x.storbinary(command, file[, blocksize) : used to store a file in binary mode. x.retrbinary(command, callback[, blocksize[, rest) : used to retrieve a file in binary mode.

There are two significant points of difference between binary and text transactions. First, both binary commands allow for the optional blocksize argument. Where text transactions occur at a pre-set (and often slower) rate, binary mode is faster. By default, data is read in blocks of 8,192 bytes. However, if you know that the network will support it, you can change that when you invoke the binary method.

Second, binary retrieval supports the optional rest argument. This argument allows you to initiate downloads in the middle of a file. This function is not supported by all FTP servers. If the FTP server does not support it, an error_reply exception is raised.

Explore Python
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Python

©2009 About.com, a part of The New York Times Company.

All rights reserved.