Package twisted :: Package protocols :: Module basic :: Class FileSender

[frames | no frames]

## Class FileSender

Known Subclasses:
  `DTPFileSender`

A producer that sends the contents of a file to a consumer.

This is a helper for protocols that, at some point, will take a file-like object, read its contents, and write them out to the network, optionally performing some transformation on the bytes in between.

This API is unstable.

Method Summary
`Deferred` | ``beginFileTransfer`(self, file, consumer, transform)` Begin transferring a file
| `pauseProducing(self)`
| `resumeProducing(self)`
| `stopProducing(self)`

Class Variable Summary
`tuple` | `__implements__` = `(<class twisted.internet.interfaces.IPr...`
`int` | `CHUNK_SIZE` = 16384
`NoneType` | `deferred` = None
`str` | `lastSent` = `''`

Method Details

### beginFileTransfer(self, file, consumer, transform=None)

Begin transferring a file

  Parameters:
    `file` - The file object to read data from
    (type=Any file-like object)
    `consumer` - The object to write data to
    (type=Any implementor of IConsumer)
    `transform` - A callable taking one string argument and returning the same. All bytes read from the file are passed through this before being written to the consumer.
  Returns:
    A deferred whose callback will be invoked when the file has been completely written to the consumer. The last byte written to the consumer is passed to the callback.
    (type=`Deferred`)

Class Variable Details

### __implements__

  Type:
    `tuple`
  Value:

        (<class twisted.internet.interfaces.IProducer at 0x827b064>,)

### CHUNK_SIZE

  Type:
    `int`
  Value:

        16384

### deferred

  Type:
    `NoneType`
  Value:

        None

### lastSent

  Type:
    `str`
  Value:

        ''

Generated by Epydoc 2.0 on Sat May 15 20:08:05 2004 | http://epydoc.sf.net