Package googleapiclient :: Module http :: Class _StreamSlice |
[hide private]
[frames] | no frames]

# Class _StreamSlice

source code

    object --+
             |
            _StreamSlice

Truncated stream.

Takes a stream and presents a stream that is a slice of the original stream. This is used when uploading media in chunks. In later versions of Python a stream can be passed to httplib in place of the string of data to send. The problem is that httplib just blindly reads to the end of the stream. This wrapper presents a virtual stream that only reads to the end of the chunk.

Instance Methods | [hide private]
__init__(self, stream, begin, chunksize) Constructor. | source code
read(self, n=-1) Read n bytes. | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, stream, begin, chunksize) (Constructor) | source code
    Constructor.

    Args:
      stream: (io.Base, file object), the stream to wrap.
      begin: int, the seek position the chunk begins at.
      chunksize: int, the size of the chunk.
Overrides: object.__init__

### read(self, n=-1) | source code
    Read n bytes.

    Args:
      n, int, the number of bytes to read.

    Returns:
      A string of length 'n', or less if EOF is reached.