class documentation

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('cow.png', mimetype='image/png',
chunksize=1024*1024, resumable=True)
farm.animals().insert(
id='cow', name='cow.png', media_body=media).execute()

Depending on the platform you are working on, you may pass -1 as the chunksize, which indicates that the entire file should be uploaded in a single request. If the underlying platform supports streams, such as Python 2.6 or later, then this can be very efficient as it avoids multiple connections, and also avoids loading the entire file into memory before sending it. Note that Google App Engine has a 5MB limit on request size, so you should never set your chunksize larger than 5MB, or to -1.

Static Method from_json Undocumented
Method __del__ Undocumented
Method __init__ Constructor.
Method to_json Creating a JSON representation of an instance of MediaFileUpload.
Instance Variable _fd Undocumented
Instance Variable _filename Undocumented

Inherited from MediaIoBaseUpload:

Method chunksize Chunk size for resumable uploads.
Method getbytes Get bytes from the media.
Method has_stream Does the underlying upload support a streaming interface.
Method mimetype Mime type of the body.
Method resumable Whether this upload is resumable.
Method size Size of upload.
Method stream A stream interface to the data being uploaded.
Instance Variable _chunksize Undocumented
Instance Variable _mimetype Undocumented
Instance Variable _resumable Undocumented
Instance Variable _size Undocumented

Inherited from MediaUpload (via MediaIoBaseUpload):

Class Method new_from_json Utility class method to instantiate a MediaUpload subclass from a JSON representation produced by to_json().
Method _to_json Utility function for creating a JSON representation of a MediaUpload.
@staticmethod
def from_json(s):

Undocumented

def __del__(self):

Undocumented

@util.positional(2)
def __init__(self, filename, mimetype=None, chunksize=DEFAULT_CHUNK_SIZE, resumable=False):

Constructor.

Parameters
filenamestring, Name of the file.
mimetypestring, Mime-type of the file. If None then a mime-type will be guessed from the file extension.
chunksizeint, File will be uploaded in chunks of this many bytes. Only used if resumable=True. Pass in a value of -1 if the file is to be uploaded in a single chunk. Note that Google App Engine has a 5MB limit on request size, so you should never set your chunksize larger than 5MB, or to -1.
resumablebool, True if this is a resumable upload. False means upload in a single request.
def to_json(self):

Creating a JSON representation of an instance of MediaFileUpload.

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

Undocumented