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