Package apiclient :: Module http :: Class MediaInMemoryUpload
[hide private]
[frames] | no frames]

Class MediaInMemoryUpload

source code


MediaUpload for a chunk of bytes.

Construct a MediaFileUpload and pass as the media_body parameter of the
method.

Instance Methods [hide private]
 
__init__(self, body, mimetype='application/octet-stream', chunksize=524288, resumable=False)
Create a new MediaBytesUpload.
source code
 
chunksize(self)
Chunk size for resumable uploads.
source code
 
mimetype(self)
Mime type of the body.
source code
 
size(self)
Size of upload.
source code
 
resumable(self)
Whether this upload is resumable.
source code
 
getbytes(self, begin, length)
Get bytes from the media.
source code
 
to_json(self)
Create a JSON representation of a MediaInMemoryUpload.
source code

Inherited from MediaUpload (private): _to_json

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]

Inherited from MediaUpload: new_from_json

Static Methods [hide private]
 
from_json(s) source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, body, mimetype='application/octet-stream', chunksize=524288, resumable=False)
(Constructor)

source code 
Create a new MediaBytesUpload.

Args:
  body: string, Bytes of body content.
  mimetype: string, Mime-type of the file or default of
    'application/octet-stream'.
  chunksize: int, File will be uploaded in chunks of this many bytes. Only
    used if resumable=True.
  resumable: bool, True if this is a resumable upload. False means upload
    in a single request.

Overrides: object.__init__

chunksize(self)

source code 
Chunk size for resumable uploads.

Returns:
  Chunk size in bytes.

Overrides: MediaUpload.chunksize

mimetype(self)

source code 
Mime type of the body.

Returns:
  Mime type.

Overrides: MediaUpload.mimetype

size(self)

source code 
Size of upload.

Returns:
  Size of the body, or None of the size is unknown.

Overrides: MediaUpload.size

resumable(self)

source code 
Whether this upload is resumable.

Returns:
  True if resumable upload or False.

Overrides: MediaUpload.resumable

getbytes(self, begin, length)

source code 
Get bytes from the media.

Args:
  begin: int, offset from beginning of file.
  length: int, number of bytes to read, starting at begin.

Returns:
  A string of bytes read. May be shorter than length if EOF was reached
  first.

Overrides: MediaUpload.getbytes

to_json(self)

source code 
Create a JSON representation of a MediaInMemoryUpload.

Returns:
   string, a JSON representation of this instance, suitable to pass to
   from_json().

Overrides: MediaUpload.to_json