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