• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0" encoding="ascii"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3          "DTD/xhtml1-transitional.dtd">
4<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5<head>
6  <title>googleapiclient.http.MediaIoBaseDownload</title>
7  <link rel="stylesheet" href="epydoc.css" type="text/css" />
8  <script type="text/javascript" src="epydoc.js"></script>
9</head>
10
11<body bgcolor="white" text="black" link="blue" vlink="#204080"
12      alink="#204080">
13<!-- ==================== NAVIGATION BAR ==================== -->
14<table class="navbar" border="0" width="100%" cellpadding="0"
15       bgcolor="#a0c0ff" cellspacing="0">
16  <tr valign="middle">
17  <!-- Home link -->
18      <th>&nbsp;&nbsp;&nbsp;<a
19        href="googleapiclient-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
20
21  <!-- Tree link -->
22      <th>&nbsp;&nbsp;&nbsp;<a
23        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
24
25  <!-- Index link -->
26      <th>&nbsp;&nbsp;&nbsp;<a
27        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
28
29  <!-- Help link -->
30      <th>&nbsp;&nbsp;&nbsp;<a
31        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
32
33      <th class="navbar" width="100%"></th>
34  </tr>
35</table>
36<table width="100%" cellpadding="0" cellspacing="0">
37  <tr valign="top">
38    <td width="100%">
39      <span class="breadcrumbs">
40        <a href="googleapiclient-module.html">Package&nbsp;googleapiclient</a> ::
41        <a href="googleapiclient.http-module.html">Module&nbsp;http</a> ::
42        Class&nbsp;MediaIoBaseDownload
43      </span>
44    </td>
45    <td>
46      <table cellpadding="0" cellspacing="0">
47        <!-- hide/show private -->
48        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
49    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
50        <tr><td align="right"><span class="options"
51            >[<a href="frames.html" target="_top">frames</a
52            >]&nbsp;|&nbsp;<a href="googleapiclient.http.MediaIoBaseDownload-class.html"
53            target="_top">no&nbsp;frames</a>]</span></td></tr>
54      </table>
55    </td>
56  </tr>
57</table>
58<!-- ==================== CLASS DESCRIPTION ==================== -->
59<h1 class="epydoc">Class MediaIoBaseDownload</h1><p class="nomargin-top"><span class="codelink"><a href="googleapiclient.http-pysrc.html#MediaIoBaseDownload">source&nbsp;code</a></span></p>
60<center>
61<center>  <map id="uml_class_diagram_for_googleap_32" name="uml_class_diagram_for_googleap_32">
62<area shape="rect" id="node1_2" href="googleapiclient.http.MediaIoBaseDownload-class.html#__init__" title="Constructor." alt="" coords="17,38,396,58"/>
63<area shape="rect" id="node1_3" href="googleapiclient.http.MediaIoBaseDownload-class.html#next_chunk" title="Get the next chunk of the download." alt="" coords="17,58,396,78"/>
64<area shape="rect" id="node1" href="googleapiclient.http.MediaIoBaseDownload-class.html" title="&quot;Download media resources." alt="" coords="5,5,408,84"/>
65</map>
66  <img src="uml_class_diagram_for_googleap_32.gif" alt='' usemap="#uml_class_diagram_for_googleap_32" ismap="ismap" class="graph-without-title" />
67</center>
68</center>
69<hr />
70<pre class="literalblock">
71&quot;Download media resources.
72
73Note that the Python file object is compatible with io.Base and can be used
74with this class also.
75
76
77Example:
78  request = farms.animals().get_media(id='cow')
79  fh = io.FileIO('cow.png', mode='wb')
80  downloader = MediaIoBaseDownload(fh, request, chunksize=1024*1024)
81
82  done = False
83  while done is False:
84    status, done = downloader.next_chunk()
85    if status:
86      print &quot;Download %d%%.&quot; % int(status.progress() * 100)
87  print &quot;Download Complete!&quot;
88
89</pre>
90
91<!-- ==================== INSTANCE METHODS ==================== -->
92<a name="section-InstanceMethods"></a>
93<table class="summary" border="1" cellpadding="3"
94       cellspacing="0" width="100%" bgcolor="white">
95<tr bgcolor="#70b0f0" class="table-header">
96  <td colspan="2" class="table-header">
97    <table border="0" cellpadding="0" cellspacing="0" width="100%">
98      <tr valign="top">
99        <td align="left"><span class="table-header">Instance Methods</span></td>
100        <td align="right" valign="top"
101         ><span class="options">[<a href="#section-InstanceMethods"
102         class="privatelink" onclick="toggle_private();"
103         >hide private</a>]</span></td>
104      </tr>
105    </table>
106  </td>
107</tr>
108<tr>
109    <td width="15%" align="right" valign="top" class="summary">
110      <span class="summary-type">&nbsp;</span>
111    </td><td class="summary">
112      <table width="100%" cellpadding="0" cellspacing="0" border="0">
113        <tr>
114          <td><span class="summary-sig"><a href="googleapiclient.http.MediaIoBaseDownload-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
115        <span class="summary-sig-arg">fd</span>,
116        <span class="summary-sig-arg">request</span>,
117        <span class="summary-sig-arg">chunksize</span>=<span class="summary-sig-default">DEFAULT_CHUNK_SIZE</span>)</span><br />
118      Constructor.</td>
119          <td align="right" valign="top">
120            <span class="codelink"><a href="googleapiclient.http-pysrc.html#MediaIoBaseDownload.__init__">source&nbsp;code</a></span>
121
122          </td>
123        </tr>
124      </table>
125
126    </td>
127  </tr>
128<tr>
129    <td width="15%" align="right" valign="top" class="summary">
130      <span class="summary-type">&nbsp;</span>
131    </td><td class="summary">
132      <table width="100%" cellpadding="0" cellspacing="0" border="0">
133        <tr>
134          <td><span class="summary-sig"><a href="googleapiclient.http.MediaIoBaseDownload-class.html#next_chunk" class="summary-sig-name">next_chunk</a>(<span class="summary-sig-arg">self</span>,
135        <span class="summary-sig-arg">num_retries</span>=<span class="summary-sig-default">0</span>)</span><br />
136      Get the next chunk of the download.</td>
137          <td align="right" valign="top">
138            <span class="codelink"><a href="googleapiclient.http-pysrc.html#MediaIoBaseDownload.next_chunk">source&nbsp;code</a></span>
139
140          </td>
141        </tr>
142      </table>
143
144    </td>
145  </tr>
146  <tr>
147    <td colspan="2" class="summary">
148    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
149      <code>__delattr__</code>,
150      <code>__format__</code>,
151      <code>__getattribute__</code>,
152      <code>__hash__</code>,
153      <code>__new__</code>,
154      <code>__reduce__</code>,
155      <code>__reduce_ex__</code>,
156      <code>__repr__</code>,
157      <code>__setattr__</code>,
158      <code>__sizeof__</code>,
159      <code>__str__</code>,
160      <code>__subclasshook__</code>
161      </p>
162    </td>
163  </tr>
164</table>
165<!-- ==================== PROPERTIES ==================== -->
166<a name="section-Properties"></a>
167<table class="summary" border="1" cellpadding="3"
168       cellspacing="0" width="100%" bgcolor="white">
169<tr bgcolor="#70b0f0" class="table-header">
170  <td colspan="2" class="table-header">
171    <table border="0" cellpadding="0" cellspacing="0" width="100%">
172      <tr valign="top">
173        <td align="left"><span class="table-header">Properties</span></td>
174        <td align="right" valign="top"
175         ><span class="options">[<a href="#section-Properties"
176         class="privatelink" onclick="toggle_private();"
177         >hide private</a>]</span></td>
178      </tr>
179    </table>
180  </td>
181</tr>
182  <tr>
183    <td colspan="2" class="summary">
184    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
185      <code>__class__</code>
186      </p>
187    </td>
188  </tr>
189</table>
190<!-- ==================== METHOD DETAILS ==================== -->
191<a name="section-MethodDetails"></a>
192<table class="details" border="1" cellpadding="3"
193       cellspacing="0" width="100%" bgcolor="white">
194<tr bgcolor="#70b0f0" class="table-header">
195  <td colspan="2" class="table-header">
196    <table border="0" cellpadding="0" cellspacing="0" width="100%">
197      <tr valign="top">
198        <td align="left"><span class="table-header">Method Details</span></td>
199        <td align="right" valign="top"
200         ><span class="options">[<a href="#section-MethodDetails"
201         class="privatelink" onclick="toggle_private();"
202         >hide private</a>]</span></td>
203      </tr>
204    </table>
205  </td>
206</tr>
207</table>
208<a name="__init__"></a>
209<div>
210<table class="details" border="1" cellpadding="3"
211       cellspacing="0" width="100%" bgcolor="white">
212<tr><td>
213  <table width="100%" cellpadding="0" cellspacing="0" border="0">
214  <tr valign="top"><td>
215  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
216        <span class="sig-arg">fd</span>,
217        <span class="sig-arg">request</span>,
218        <span class="sig-arg">chunksize</span>=<span class="sig-default">DEFAULT_CHUNK_SIZE</span>)</span>
219    <br /><em class="fname">(Constructor)</em>
220  </h3>
221  </td><td align="right" valign="top"
222    ><span class="codelink"><a href="googleapiclient.http-pysrc.html#MediaIoBaseDownload.__init__">source&nbsp;code</a></span>&nbsp;
223    </td>
224  </tr></table>
225
226  <pre class="literalblock">
227Constructor.
228
229Args:
230  fd: io.Base or file object, The stream in which to write the downloaded
231    bytes.
232  request: googleapiclient.http.HttpRequest, the media request to perform in
233    chunks.
234  chunksize: int, File will be downloaded in chunks of this many bytes.
235
236</pre>
237  <dl class="fields">
238    <dt>Decorators:</dt>
239    <dd><ul class="nomargin-top">
240        <li><code>@util.positional(3)</code></li>
241    </ul></dd>
242    <dt>Overrides:
243        object.__init__
244    </dt>
245  </dl>
246</td></tr></table>
247</div>
248<a name="next_chunk"></a>
249<div>
250<table class="details" border="1" cellpadding="3"
251       cellspacing="0" width="100%" bgcolor="white">
252<tr><td>
253  <table width="100%" cellpadding="0" cellspacing="0" border="0">
254  <tr valign="top"><td>
255  <h3 class="epydoc"><span class="sig"><span class="sig-name">next_chunk</span>(<span class="sig-arg">self</span>,
256        <span class="sig-arg">num_retries</span>=<span class="sig-default">0</span>)</span>
257  </h3>
258  </td><td align="right" valign="top"
259    ><span class="codelink"><a href="googleapiclient.http-pysrc.html#MediaIoBaseDownload.next_chunk">source&nbsp;code</a></span>&nbsp;
260    </td>
261  </tr></table>
262
263  <pre class="literalblock">
264Get the next chunk of the download.
265
266Args:
267  num_retries: Integer, number of times to retry with randomized
268        exponential backoff. If all retries fail, the raised HttpError
269        represents the last request. If zero (default), we attempt the
270        request only once.
271
272Returns:
273  (status, done): (MediaDownloadProgress, boolean)
274     The value of 'done' will be True when the media has been fully
275     downloaded or the total size of the media is unknown.
276
277Raises:
278  googleapiclient.errors.HttpError if the response was not a 2xx.
279  httplib2.HttpLib2Error if a transport error has occured.
280
281</pre>
282  <dl class="fields">
283    <dt>Decorators:</dt>
284    <dd><ul class="nomargin-top">
285        <li><code>@util.positional(1)</code></li>
286    </ul></dd>
287  </dl>
288</td></tr></table>
289</div>
290<br />
291<!-- ==================== NAVIGATION BAR ==================== -->
292<table class="navbar" border="0" width="100%" cellpadding="0"
293       bgcolor="#a0c0ff" cellspacing="0">
294  <tr valign="middle">
295  <!-- Home link -->
296      <th>&nbsp;&nbsp;&nbsp;<a
297        href="googleapiclient-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
298
299  <!-- Tree link -->
300      <th>&nbsp;&nbsp;&nbsp;<a
301        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
302
303  <!-- Index link -->
304      <th>&nbsp;&nbsp;&nbsp;<a
305        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
306
307  <!-- Help link -->
308      <th>&nbsp;&nbsp;&nbsp;<a
309        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
310
311      <th class="navbar" width="100%"></th>
312  </tr>
313</table>
314<table border="0" cellpadding="0" cellspacing="0" width="100%%">
315  <tr>
316    <td align="left" class="footer">
317    Generated by Epydoc 3.0.1 on Fri Jun 14 15:57:28 2019
318    </td>
319    <td align="right" class="footer">
320      <a target="mainFrame" href="http://epydoc.sourceforge.net"
321        >http://epydoc.sourceforge.net</a>
322    </td>
323  </tr>
324</table>
325
326<script type="text/javascript">
327  <!--
328  // Private objects are initially displayed (because if
329  // javascript is turned off then we want them to be
330  // visible); but by default, we want to hide them.  So hide
331  // them unless we have a cookie that says to show them.
332  checkCookie();
333  // -->
334</script>
335</body>
336</html>
337