class documentation

class MediaIoBaseDownload(object):

Constructor: MediaIoBaseDownload(fd, request, chunksize)

View In Hierarchy

"Download media resources.

Note that the Python file object is compatible with io.Base and can be used with this class also.

Example

request = farms.animals().get_media(id='cow') fh = io.FileIO('cow.png', mode='wb') downloader = MediaIoBaseDownload(fh, request, chunksize=1024*1024)

done = False while done is False:

status, done = downloader.next_chunk() if status:

print "Download %d%%." % int(status.progress() * 100)

print "Download Complete!"

Method __init__ Constructor.
Method next_chunk Get the next chunk of the download.
Instance Variable _chunksize Undocumented
Instance Variable _done Undocumented
Instance Variable _fd Undocumented
Instance Variable _headers Undocumented
Instance Variable _progress Undocumented
Instance Variable _rand Undocumented
Instance Variable _request Undocumented
Instance Variable _sleep Undocumented
Instance Variable _total_size Undocumented
Instance Variable _uri Undocumented
@util.positional(3)
def __init__(self, fd, request, chunksize=DEFAULT_CHUNK_SIZE):

Constructor.

Parameters
fdio.Base or file object, The stream in which to write the downloaded bytes.
requestgoogleapiclient.http.HttpRequest, the media request to perform in chunks.
chunksizeint, File will be downloaded in chunks of this many bytes.
@util.positional(1)
def next_chunk(self, num_retries=0):

Get the next chunk of the download.

Parameters
num_retriesInteger, number of times to retry with randomized exponential backoff. If all retries fail, the raised HttpError represents the last request. If zero (default), we attempt the request only once.
Returns
(status, done)
(MediaDownloadProgress, boolean)
The value of 'done' will be True when the media has been fully downloaded or the total size of the media is unknown.
Raises
googleapiclient.errors.HttpError if the response was not a 2xx.
httplib2.HttpLib2Error if a transport error has occurred.
_chunksize =

Undocumented

_done: bool =

Undocumented

_fd =

Undocumented

_headers: dict =

Undocumented

_progress: int =

Undocumented

_rand =

Undocumented

_request =

Undocumented

_sleep =

Undocumented

_total_size =

Undocumented

_uri =

Undocumented