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

Class MediaFileUpload

source code


A MediaUpload for a file.

Construct a MediaFileUpload and pass as the media_body parameter of the
method. For example, if we had a service that allowed uploading images:


  media = MediaFileUpload('smiley.png', mimetype='image/png', chunksize=1000,
                  resumable=True)
  service.objects().insert(
      bucket=buckets['items'][0]['id'],
      name='smiley.png',
      media_body=media).execute()

Instance Methods [hide private]
 
__init__(self, filename, mimetype=None, chunksize=262144, resumable=False)
Constructor.
source code
 
mimetype(self) source code
 
size(self) source code
 
chunksize(self) source code
 
resumable(self) source code
 
getbytes(self, begin, length)
Get bytes from the media.
source code
 
to_json(self)
Creating a JSON representation of an instance of Credentials.
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, filename, mimetype=None, chunksize=262144, resumable=False)
(Constructor)

source code 
Constructor.

Args:
  filename: string, Name of the file.
  mimetype: string, Mime-type of the file. If None then a mime-type will be
    guessed from the file extension.
  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__

mimetype(self)

source code 
Overrides: MediaUpload.mimetype

size(self)

source code 
Overrides: MediaUpload.size

chunksize(self)

source code 
Overrides: MediaUpload.chunksize

resumable(self)

source code 
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 shorted than length if EOF was reached
  first.

Overrides: MediaUpload.getbytes

to_json(self)

source code 
Creating a JSON representation of an instance of Credentials.

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

Overrides: MediaUpload.to_json