Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -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.MediaFileUpload</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 MediaFileUpload |
| 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.MediaFileUpload-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 MediaFileUpload</h1><p class="nomargin-top"><span class="codelink"><a href="apiclient.http-pysrc.html#MediaFileUpload">source code</a></span></p> |
| 57 | <center> |
Joe Gregorio | 746096f | 2012-06-15 10:53:36 -0400 | [diff] [blame] | 58 | <center> <map id="class_hierarchy_for_mediafileu" name="class_hierarchy_for_mediafileu"> |
Joe Gregorio | 1b425aa | 2012-08-24 12:04:34 -0400 | [diff] [blame^] | 59 | <area shape="rect" href="apiclient.http.MediaFileUpload-class.html" title="MediaFileUpload" alt="" coords="15,117,132,144"/> |
| 60 | <area shape="rect" href="apiclient.http.MediaIoBaseUpload-class.html" title="MediaIoBaseUpload" alt="" coords="5,61,141,88"/> |
| 61 | <area shape="rect" href="apiclient.http.MediaUpload-class.html" title="MediaUpload" alt="" coords="25,5,121,32"/> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 62 | </map> |
Joe Gregorio | 746096f | 2012-06-15 10:53:36 -0400 | [diff] [blame] | 63 | <img src="class_hierarchy_for_mediafileu.gif" alt='' usemap="#class_hierarchy_for_mediafileu" ismap="ismap" class="graph-without-title" /> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 64 | </center> |
| 65 | </center> |
| 66 | <hr /> |
| 67 | <pre class="literalblock"> |
| 68 | A MediaUpload for a file. |
| 69 | |
| 70 | Construct a MediaFileUpload and pass as the media_body parameter of the |
| 71 | method. For example, if we had a service that allowed uploading images: |
| 72 | |
| 73 | |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 74 | media = MediaFileUpload('cow.png', mimetype='image/png', |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 75 | chunksize=1024*1024, resumable=True) |
Joe Gregorio | 1b425aa | 2012-08-24 12:04:34 -0400 | [diff] [blame^] | 76 | farm.animals().insert( |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 77 | id='cow', |
| 78 | name='cow.png', |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 79 | media_body=media).execute() |
| 80 | |
Joe Gregorio | 1b425aa | 2012-08-24 12:04:34 -0400 | [diff] [blame^] | 81 | Depending on the platform you are working on, you may pass -1 as the |
| 82 | chunksize, which indicates that the entire file should be uploaded in a single |
| 83 | request. If the underlying platform supports streams, such as Python 2.6 or |
| 84 | later, then this can be very efficient as it avoids multiple connections, and |
| 85 | also avoids loading the entire file into memory before sending it. Note that |
| 86 | Google App Engine has a 5MB limit on request size, so you should never set |
| 87 | your chunksize larger than 5MB, or to -1. |
| 88 | |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 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"> </span> |
| 111 | </td><td class="summary"> |
| 112 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 113 | <tr> |
Joe Gregorio | 1b425aa | 2012-08-24 12:04:34 -0400 | [diff] [blame^] | 114 | <td><span class="summary-sig"><a href="apiclient.http.MediaFileUpload-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">*args</span>, |
| 115 | <span class="summary-sig-arg">**kwargs</span>)</span><br /> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 116 | Constructor.</td> |
| 117 | <td align="right" valign="top"> |
Joe Gregorio | 1b425aa | 2012-08-24 12:04:34 -0400 | [diff] [blame^] | 118 | <span class="codelink"><a href="oauth2client.util-pysrc.html">source code</a></span> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 119 | |
| 120 | </td> |
| 121 | </tr> |
| 122 | </table> |
| 123 | |
| 124 | </td> |
| 125 | </tr> |
| 126 | <tr> |
| 127 | <td width="15%" align="right" valign="top" class="summary"> |
| 128 | <span class="summary-type"> </span> |
| 129 | </td><td class="summary"> |
| 130 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 131 | <tr> |
| 132 | <td><span class="summary-sig"><a href="apiclient.http.MediaFileUpload-class.html#to_json" class="summary-sig-name">to_json</a>(<span class="summary-sig-arg">self</span>)</span><br /> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 133 | Creating a JSON representation of an instance of MediaFileUpload.</td> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 134 | <td align="right" valign="top"> |
| 135 | <span class="codelink"><a href="apiclient.http-pysrc.html#MediaFileUpload.to_json">source code</a></span> |
| 136 | |
| 137 | </td> |
| 138 | </tr> |
| 139 | </table> |
| 140 | |
| 141 | </td> |
| 142 | </tr> |
| 143 | <tr> |
| 144 | <td colspan="2" class="summary"> |
Joe Gregorio | 1b425aa | 2012-08-24 12:04:34 -0400 | [diff] [blame^] | 145 | <p class="indent-wrapped-lines"><b>Inherited from <code><a href="apiclient.http.MediaIoBaseUpload-class.html">MediaIoBaseUpload</a></code></b>: |
| 146 | <code><a href="apiclient.http.MediaIoBaseUpload-class.html#chunksize">chunksize</a></code>, |
| 147 | <code><a href="apiclient.http.MediaIoBaseUpload-class.html#getbytes">getbytes</a></code>, |
| 148 | <code><a href="apiclient.http.MediaIoBaseUpload-class.html#has_stream">has_stream</a></code>, |
| 149 | <code><a href="apiclient.http.MediaIoBaseUpload-class.html#mimetype">mimetype</a></code>, |
| 150 | <code><a href="apiclient.http.MediaIoBaseUpload-class.html#resumable">resumable</a></code>, |
| 151 | <code><a href="apiclient.http.MediaIoBaseUpload-class.html#size">size</a></code>, |
| 152 | <code><a href="apiclient.http.MediaIoBaseUpload-class.html#stream">stream</a></code> |
| 153 | </p> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 154 | <div class="private"> <p class="indent-wrapped-lines"><b>Inherited from <code><a href="apiclient.http.MediaUpload-class.html">MediaUpload</a></code></b> (private): |
| 155 | <code><a href="apiclient.http.MediaUpload-class.html#_to_json" onclick="show_private();">_to_json</a></code> |
| 156 | </p></div> |
| 157 | <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>: |
| 158 | <code>__delattr__</code>, |
| 159 | <code>__format__</code>, |
| 160 | <code>__getattribute__</code>, |
| 161 | <code>__hash__</code>, |
| 162 | <code>__new__</code>, |
| 163 | <code>__reduce__</code>, |
| 164 | <code>__reduce_ex__</code>, |
| 165 | <code>__repr__</code>, |
| 166 | <code>__setattr__</code>, |
| 167 | <code>__sizeof__</code>, |
| 168 | <code>__str__</code>, |
| 169 | <code>__subclasshook__</code> |
| 170 | </p> |
| 171 | </td> |
| 172 | </tr> |
| 173 | </table> |
| 174 | <!-- ==================== CLASS METHODS ==================== --> |
| 175 | <a name="section-ClassMethods"></a> |
| 176 | <table class="summary" border="1" cellpadding="3" |
| 177 | cellspacing="0" width="100%" bgcolor="white"> |
| 178 | <tr bgcolor="#70b0f0" class="table-header"> |
| 179 | <td colspan="2" class="table-header"> |
| 180 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 181 | <tr valign="top"> |
| 182 | <td align="left"><span class="table-header">Class Methods</span></td> |
| 183 | <td align="right" valign="top" |
| 184 | ><span class="options">[<a href="#section-ClassMethods" |
| 185 | class="privatelink" onclick="toggle_private();" |
| 186 | >hide private</a>]</span></td> |
| 187 | </tr> |
| 188 | </table> |
| 189 | </td> |
| 190 | </tr> |
| 191 | <tr> |
| 192 | <td colspan="2" class="summary"> |
| 193 | <p class="indent-wrapped-lines"><b>Inherited from <code><a href="apiclient.http.MediaUpload-class.html">MediaUpload</a></code></b>: |
| 194 | <code><a href="apiclient.http.MediaUpload-class.html#new_from_json">new_from_json</a></code> |
| 195 | </p> |
| 196 | </td> |
| 197 | </tr> |
| 198 | </table> |
| 199 | <!-- ==================== STATIC METHODS ==================== --> |
| 200 | <a name="section-StaticMethods"></a> |
| 201 | <table class="summary" border="1" cellpadding="3" |
| 202 | cellspacing="0" width="100%" bgcolor="white"> |
| 203 | <tr bgcolor="#70b0f0" class="table-header"> |
| 204 | <td colspan="2" class="table-header"> |
| 205 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 206 | <tr valign="top"> |
| 207 | <td align="left"><span class="table-header">Static Methods</span></td> |
| 208 | <td align="right" valign="top" |
| 209 | ><span class="options">[<a href="#section-StaticMethods" |
| 210 | class="privatelink" onclick="toggle_private();" |
| 211 | >hide private</a>]</span></td> |
| 212 | </tr> |
| 213 | </table> |
| 214 | </td> |
| 215 | </tr> |
| 216 | <tr> |
| 217 | <td width="15%" align="right" valign="top" class="summary"> |
| 218 | <span class="summary-type"> </span> |
| 219 | </td><td class="summary"> |
| 220 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 221 | <tr> |
| 222 | <td><span class="summary-sig"><a name="from_json"></a><span class="summary-sig-name">from_json</span>(<span class="summary-sig-arg">s</span>)</span></td> |
| 223 | <td align="right" valign="top"> |
| 224 | <span class="codelink"><a href="apiclient.http-pysrc.html#MediaFileUpload.from_json">source code</a></span> |
| 225 | |
| 226 | </td> |
| 227 | </tr> |
| 228 | </table> |
| 229 | |
| 230 | </td> |
| 231 | </tr> |
| 232 | </table> |
| 233 | <!-- ==================== PROPERTIES ==================== --> |
| 234 | <a name="section-Properties"></a> |
| 235 | <table class="summary" border="1" cellpadding="3" |
| 236 | cellspacing="0" width="100%" bgcolor="white"> |
| 237 | <tr bgcolor="#70b0f0" class="table-header"> |
| 238 | <td colspan="2" class="table-header"> |
| 239 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 240 | <tr valign="top"> |
| 241 | <td align="left"><span class="table-header">Properties</span></td> |
| 242 | <td align="right" valign="top" |
| 243 | ><span class="options">[<a href="#section-Properties" |
| 244 | class="privatelink" onclick="toggle_private();" |
| 245 | >hide private</a>]</span></td> |
| 246 | </tr> |
| 247 | </table> |
| 248 | </td> |
| 249 | </tr> |
| 250 | <tr> |
| 251 | <td colspan="2" class="summary"> |
| 252 | <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>: |
| 253 | <code>__class__</code> |
| 254 | </p> |
| 255 | </td> |
| 256 | </tr> |
| 257 | </table> |
| 258 | <!-- ==================== METHOD DETAILS ==================== --> |
| 259 | <a name="section-MethodDetails"></a> |
| 260 | <table class="details" border="1" cellpadding="3" |
| 261 | cellspacing="0" width="100%" bgcolor="white"> |
| 262 | <tr bgcolor="#70b0f0" class="table-header"> |
| 263 | <td colspan="2" class="table-header"> |
| 264 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 265 | <tr valign="top"> |
| 266 | <td align="left"><span class="table-header">Method Details</span></td> |
| 267 | <td align="right" valign="top" |
| 268 | ><span class="options">[<a href="#section-MethodDetails" |
| 269 | class="privatelink" onclick="toggle_private();" |
| 270 | >hide private</a>]</span></td> |
| 271 | </tr> |
| 272 | </table> |
| 273 | </td> |
| 274 | </tr> |
| 275 | </table> |
| 276 | <a name="__init__"></a> |
| 277 | <div> |
| 278 | <table class="details" border="1" cellpadding="3" |
| 279 | cellspacing="0" width="100%" bgcolor="white"> |
| 280 | <tr><td> |
| 281 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 282 | <tr valign="top"><td> |
Joe Gregorio | 1b425aa | 2012-08-24 12:04:34 -0400 | [diff] [blame^] | 283 | <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">*args</span>, |
| 284 | <span class="sig-arg">**kwargs</span>)</span> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 285 | <br /><em class="fname">(Constructor)</em> |
| 286 | </h3> |
| 287 | </td><td align="right" valign="top" |
Joe Gregorio | 1b425aa | 2012-08-24 12:04:34 -0400 | [diff] [blame^] | 288 | ><span class="codelink"><a href="oauth2client.util-pysrc.html">source code</a></span> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 289 | </td> |
| 290 | </tr></table> |
| 291 | |
| 292 | <pre class="literalblock"> |
| 293 | Constructor. |
| 294 | |
| 295 | Args: |
| 296 | filename: string, Name of the file. |
| 297 | mimetype: string, Mime-type of the file. If None then a mime-type will be |
| 298 | guessed from the file extension. |
| 299 | chunksize: int, File will be uploaded in chunks of this many bytes. Only |
Joe Gregorio | 1b425aa | 2012-08-24 12:04:34 -0400 | [diff] [blame^] | 300 | used if resumable=True. Pass in a value of -1 if the file is to be |
| 301 | uploaded in a single chunk. Note that Google App Engine has a 5MB limit |
| 302 | on request size, so you should never set your chunksize larger than 5MB, |
| 303 | or to -1. |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 304 | resumable: bool, True if this is a resumable upload. False means upload |
| 305 | in a single request. |
| 306 | |
| 307 | </pre> |
| 308 | <dl class="fields"> |
Joe Gregorio | 1b425aa | 2012-08-24 12:04:34 -0400 | [diff] [blame^] | 309 | <dt>Decorators:</dt> |
| 310 | <dd><ul class="nomargin-top"> |
| 311 | <li><code>@util.positional(2)</code></li> |
| 312 | </ul></dd> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 313 | <dt>Overrides: |
| 314 | object.__init__ |
| 315 | </dt> |
| 316 | </dl> |
| 317 | </td></tr></table> |
| 318 | </div> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 319 | <a name="to_json"></a> |
| 320 | <div> |
| 321 | <table class="details" border="1" cellpadding="3" |
| 322 | cellspacing="0" width="100%" bgcolor="white"> |
| 323 | <tr><td> |
| 324 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 325 | <tr valign="top"><td> |
| 326 | <h3 class="epydoc"><span class="sig"><span class="sig-name">to_json</span>(<span class="sig-arg">self</span>)</span> |
| 327 | </h3> |
| 328 | </td><td align="right" valign="top" |
| 329 | ><span class="codelink"><a href="apiclient.http-pysrc.html#MediaFileUpload.to_json">source code</a></span> |
| 330 | </td> |
| 331 | </tr></table> |
| 332 | |
| 333 | <pre class="literalblock"> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 334 | Creating a JSON representation of an instance of MediaFileUpload. |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 335 | |
| 336 | Returns: |
| 337 | string, a JSON representation of this instance, suitable to pass to |
| 338 | from_json(). |
| 339 | |
| 340 | </pre> |
| 341 | <dl class="fields"> |
| 342 | <dt>Overrides: |
| 343 | <a href="apiclient.http.MediaUpload-class.html#to_json">MediaUpload.to_json</a> |
| 344 | </dt> |
| 345 | </dl> |
| 346 | </td></tr></table> |
| 347 | </div> |
| 348 | <br /> |
| 349 | <!-- ==================== NAVIGATION BAR ==================== --> |
| 350 | <table class="navbar" border="0" width="100%" cellpadding="0" |
| 351 | bgcolor="#a0c0ff" cellspacing="0"> |
| 352 | <tr valign="middle"> |
| 353 | |
| 354 | <!-- Tree link --> |
| 355 | <th> <a |
| 356 | href="module-tree.html">Trees</a> </th> |
| 357 | |
| 358 | <!-- Index link --> |
| 359 | <th> <a |
| 360 | href="identifier-index.html">Indices</a> </th> |
| 361 | |
| 362 | <!-- Help link --> |
| 363 | <th> <a |
| 364 | href="help.html">Help</a> </th> |
| 365 | |
| 366 | <th class="navbar" width="100%"></th> |
| 367 | </tr> |
| 368 | </table> |
| 369 | <table border="0" cellpadding="0" cellspacing="0" width="100%%"> |
| 370 | <tr> |
| 371 | <td align="left" class="footer"> |
Joe Gregorio | 1b425aa | 2012-08-24 12:04:34 -0400 | [diff] [blame^] | 372 | Generated by Epydoc 3.0.1 on Fri Aug 24 11:02:02 2012 |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 373 | </td> |
| 374 | <td align="right" class="footer"> |
| 375 | <a target="mainFrame" href="http://epydoc.sourceforge.net" |
| 376 | >http://epydoc.sourceforge.net</a> |
| 377 | </td> |
| 378 | </tr> |
| 379 | </table> |
| 380 | |
| 381 | <script type="text/javascript"> |
| 382 | <!-- |
| 383 | // Private objects are initially displayed (because if |
| 384 | // javascript is turned off then we want them to be |
| 385 | // visible); but by default, we want to hide them. So hide |
| 386 | // them unless we have a cookie that says to show them. |
| 387 | checkCookie(); |
| 388 | // --> |
| 389 | </script> |
| 390 | </body> |
| 391 | </html> |