class documentation
class MediaIoBaseDownload(object):
Constructor: MediaIoBaseDownload(fd, request, chunksize)
"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 |
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 |
Undocumented |
| Instance Variable | _uri |
Undocumented |
Constructor.
| Parameters | |
| fd | io.Base or file object, The stream in which to write the downloaded bytes. |
| request | googleapiclient.http.HttpRequest, the media request to perform in chunks. |
| chunksize | int, File will be downloaded in chunks of this many bytes. |
Get the next chunk of the download.
| Parameters | |
| num | Integer, 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) |
|
| Raises | |
googleapiclient.errors.HttpError if the response was not a 2xx. | |
httplib2.HttpLib2Error if a transport error has occurred. | |