| Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 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>apiclient.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 |  | 
|  | 18 | <!-- Tree link --> | 
|  | 19 | <th>   <a | 
|  | 20 | href="module-tree.html">Trees</a>   </th> | 
|  | 21 |  | 
|  | 22 | <!-- Index link --> | 
|  | 23 | <th>   <a | 
|  | 24 | href="identifier-index.html">Indices</a>   </th> | 
|  | 25 |  | 
|  | 26 | <!-- Help link --> | 
|  | 27 | <th>   <a | 
|  | 28 | href="help.html">Help</a>   </th> | 
|  | 29 |  | 
|  | 30 | <th class="navbar" width="100%"></th> | 
|  | 31 | </tr> | 
|  | 32 | </table> | 
|  | 33 | <table width="100%" cellpadding="0" cellspacing="0"> | 
|  | 34 | <tr valign="top"> | 
|  | 35 | <td width="100%"> | 
|  | 36 | <span class="breadcrumbs"> | 
|  | 37 | <a href="apiclient-module.html">Package apiclient</a> :: | 
|  | 38 | <a href="apiclient.http-module.html">Module http</a> :: | 
|  | 39 | Class MediaIoBaseDownload | 
|  | 40 | </span> | 
|  | 41 | </td> | 
|  | 42 | <td> | 
|  | 43 | <table cellpadding="0" cellspacing="0"> | 
|  | 44 | <!-- hide/show private --> | 
|  | 45 | <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink" | 
|  | 46 | onclick="toggle_private();">hide private</a>]</span></td></tr> | 
|  | 47 | <tr><td align="right"><span class="options" | 
|  | 48 | >[<a href="frames.html" target="_top">frames</a | 
|  | 49 | >] | <a href="apiclient.http.MediaIoBaseDownload-class.html" | 
|  | 50 | target="_top">no frames</a>]</span></td></tr> | 
|  | 51 | </table> | 
|  | 52 | </td> | 
|  | 53 | </tr> | 
|  | 54 | </table> | 
|  | 55 | <!-- ==================== CLASS DESCRIPTION ==================== --> | 
|  | 56 | <h1 class="epydoc">Class MediaIoBaseDownload</h1><p class="nomargin-top"><span class="codelink"><a href="apiclient.http-pysrc.html#MediaIoBaseDownload">source code</a></span></p> | 
|  | 57 | <center> | 
|  | 58 | <center>  <map id="class_hierarchy_for_mediaiobas" name="class_hierarchy_for_mediaiobas"> | 
|  | 59 | <area shape="rect" href="apiclient.http.MediaIoBaseDownload-class.html" title="MediaIoBaseDownload" alt="" coords="5,5,157,32"/> | 
|  | 60 | </map> | 
|  | 61 | <img src="class_hierarchy_for_mediaiobas.gif" alt='' usemap="#class_hierarchy_for_mediaiobas" ismap="ismap" class="graph-without-title" /> | 
|  | 62 | </center> | 
|  | 63 | </center> | 
|  | 64 | <hr /> | 
|  | 65 | <pre class="literalblock"> | 
|  | 66 | "Download media resources. | 
|  | 67 |  | 
|  | 68 | Note that the Python file object is compatible with io.Base and can be used | 
|  | 69 | with this class also. | 
|  | 70 |  | 
|  | 71 |  | 
|  | 72 | Example: | 
|  | 73 | request = farms.animals().get_media(id='cow') | 
|  | 74 | fh = io.FileIO('cow.png', mode='wb') | 
|  | 75 | downloader = MediaIoBaseDownload(fh, request, chunksize=1024*1024) | 
|  | 76 |  | 
|  | 77 | done = False | 
|  | 78 | while done is False: | 
|  | 79 | status, done = downloader.next_chunk() | 
|  | 80 | if status: | 
|  | 81 | print "Download %d%%." % int(status.progress() * 100) | 
|  | 82 | print "Download Complete!" | 
|  | 83 |  | 
|  | 84 | </pre> | 
|  | 85 |  | 
|  | 86 | <!-- ==================== INSTANCE METHODS ==================== --> | 
|  | 87 | <a name="section-InstanceMethods"></a> | 
|  | 88 | <table class="summary" border="1" cellpadding="3" | 
|  | 89 | cellspacing="0" width="100%" bgcolor="white"> | 
|  | 90 | <tr bgcolor="#70b0f0" class="table-header"> | 
|  | 91 | <td colspan="2" class="table-header"> | 
|  | 92 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> | 
|  | 93 | <tr valign="top"> | 
|  | 94 | <td align="left"><span class="table-header">Instance Methods</span></td> | 
|  | 95 | <td align="right" valign="top" | 
|  | 96 | ><span class="options">[<a href="#section-InstanceMethods" | 
|  | 97 | class="privatelink" onclick="toggle_private();" | 
|  | 98 | >hide private</a>]</span></td> | 
|  | 99 | </tr> | 
|  | 100 | </table> | 
|  | 101 | </td> | 
|  | 102 | </tr> | 
|  | 103 | <tr> | 
|  | 104 | <td width="15%" align="right" valign="top" class="summary"> | 
|  | 105 | <span class="summary-type"> </span> | 
|  | 106 | </td><td class="summary"> | 
|  | 107 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> | 
|  | 108 | <tr> | 
|  | 109 | <td><span class="summary-sig"><a href="apiclient.http.MediaIoBaseDownload-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>, | 
|  | 110 | <span class="summary-sig-arg">fh</span>, | 
|  | 111 | <span class="summary-sig-arg">request</span>, | 
|  | 112 | <span class="summary-sig-arg">chunksize</span>=<span class="summary-sig-default">524288</span>)</span><br /> | 
|  | 113 | Constructor.</td> | 
|  | 114 | <td align="right" valign="top"> | 
|  | 115 | <span class="codelink"><a href="apiclient.http-pysrc.html#MediaIoBaseDownload.__init__">source code</a></span> | 
|  | 116 |  | 
|  | 117 | </td> | 
|  | 118 | </tr> | 
|  | 119 | </table> | 
|  | 120 |  | 
|  | 121 | </td> | 
|  | 122 | </tr> | 
|  | 123 | <tr> | 
|  | 124 | <td width="15%" align="right" valign="top" class="summary"> | 
|  | 125 | <span class="summary-type"> </span> | 
|  | 126 | </td><td class="summary"> | 
|  | 127 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> | 
|  | 128 | <tr> | 
|  | 129 | <td><span class="summary-sig"><a href="apiclient.http.MediaIoBaseDownload-class.html#next_chunk" class="summary-sig-name">next_chunk</a>(<span class="summary-sig-arg">self</span>)</span><br /> | 
|  | 130 | Get the next chunk of the download.</td> | 
|  | 131 | <td align="right" valign="top"> | 
|  | 132 | <span class="codelink"><a href="apiclient.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">fh</span>, | 
|  | 211 | <span class="sig-arg">request</span>, | 
|  | 212 | <span class="sig-arg">chunksize</span>=<span class="sig-default">524288</span>)</span> | 
|  | 213 | <br /><em class="fname">(Constructor)</em> | 
|  | 214 | </h3> | 
|  | 215 | </td><td align="right" valign="top" | 
|  | 216 | ><span class="codelink"><a href="apiclient.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 | fh: io.Base or file object, The stream in which to write the downloaded | 
|  | 225 | bytes. | 
|  | 226 | request: apiclient.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>Overrides: | 
|  | 233 | object.__init__ | 
|  | 234 | </dt> | 
|  | 235 | </dl> | 
|  | 236 | </td></tr></table> | 
|  | 237 | </div> | 
|  | 238 | <a name="next_chunk"></a> | 
|  | 239 | <div> | 
|  | 240 | <table class="details" border="1" cellpadding="3" | 
|  | 241 | cellspacing="0" width="100%" bgcolor="white"> | 
|  | 242 | <tr><td> | 
|  | 243 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> | 
|  | 244 | <tr valign="top"><td> | 
|  | 245 | <h3 class="epydoc"><span class="sig"><span class="sig-name">next_chunk</span>(<span class="sig-arg">self</span>)</span> | 
|  | 246 | </h3> | 
|  | 247 | </td><td align="right" valign="top" | 
|  | 248 | ><span class="codelink"><a href="apiclient.http-pysrc.html#MediaIoBaseDownload.next_chunk">source code</a></span>  | 
|  | 249 | </td> | 
|  | 250 | </tr></table> | 
|  | 251 |  | 
|  | 252 | <pre class="literalblock"> | 
|  | 253 | Get the next chunk of the download. | 
|  | 254 |  | 
|  | 255 | Returns: | 
|  | 256 | (status, done): (MediaDownloadStatus, boolean) | 
|  | 257 | The value of 'done' will be True when the media has been fully | 
|  | 258 | downloaded. | 
|  | 259 |  | 
|  | 260 | Raises: | 
|  | 261 | apiclient.errors.HttpError if the response was not a 2xx. | 
|  | 262 | httplib2.Error if a transport error has occured. | 
|  | 263 |  | 
|  | 264 | </pre> | 
|  | 265 | <dl class="fields"> | 
|  | 266 | </dl> | 
|  | 267 | </td></tr></table> | 
|  | 268 | </div> | 
|  | 269 | <br /> | 
|  | 270 | <!-- ==================== NAVIGATION BAR ==================== --> | 
|  | 271 | <table class="navbar" border="0" width="100%" cellpadding="0" | 
|  | 272 | bgcolor="#a0c0ff" cellspacing="0"> | 
|  | 273 | <tr valign="middle"> | 
|  | 274 |  | 
|  | 275 | <!-- Tree link --> | 
|  | 276 | <th>   <a | 
|  | 277 | href="module-tree.html">Trees</a>   </th> | 
|  | 278 |  | 
|  | 279 | <!-- Index link --> | 
|  | 280 | <th>   <a | 
|  | 281 | href="identifier-index.html">Indices</a>   </th> | 
|  | 282 |  | 
|  | 283 | <!-- Help link --> | 
|  | 284 | <th>   <a | 
|  | 285 | href="help.html">Help</a>   </th> | 
|  | 286 |  | 
|  | 287 | <th class="navbar" width="100%"></th> | 
|  | 288 | </tr> | 
|  | 289 | </table> | 
|  | 290 | <table border="0" cellpadding="0" cellspacing="0" width="100%%"> | 
|  | 291 | <tr> | 
|  | 292 | <td align="left" class="footer"> | 
| Joe Gregorio | bf14cef | 2012-06-22 15:26:16 -0400 | [diff] [blame] | 293 | Generated by Epydoc 3.0.1 on Fri Jun 22 14:19:32 2012 | 
| Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 294 | </td> | 
|  | 295 | <td align="right" class="footer"> | 
|  | 296 | <a target="mainFrame" href="http://epydoc.sourceforge.net" | 
|  | 297 | >http://epydoc.sourceforge.net</a> | 
|  | 298 | </td> | 
|  | 299 | </tr> | 
|  | 300 | </table> | 
|  | 301 |  | 
|  | 302 | <script type="text/javascript"> | 
|  | 303 | <!-- | 
|  | 304 | // Private objects are initially displayed (because if | 
|  | 305 | // javascript is turned off then we want them to be | 
|  | 306 | // visible); but by default, we want to hide them.  So hide | 
|  | 307 | // them unless we have a cookie that says to show them. | 
|  | 308 | checkCookie(); | 
|  | 309 | // --> | 
|  | 310 | </script> | 
|  | 311 | </body> | 
|  | 312 | </html> |