Most viewed recipes tagged "upload"http://code.activestate.com/recipes/tags/upload/views/2015-12-06T19:23:54-08:00ActiveState Code RecipesEncode multipart form data for uploading files via POST (Python)
2013-09-22T21:27:24-07:00Ben Hoythttp://code.activestate.com/recipes/users/4170919/http://code.activestate.com/recipes/578668-encode-multipart-form-data-for-uploading-files-via/
<p style="color: grey">
Python
recipe 578668
by <a href="/recipes/users/4170919/">Ben Hoyt</a>
(<a href="/recipes/tags/form/">form</a>, <a href="/recipes/tags/http/">http</a>, <a href="/recipes/tags/multipart/">multipart</a>, <a href="/recipes/tags/upload/">upload</a>).
</p>
<p>This function lets you encode form fields <em>and</em> files in multipart/form-data format for uploading files via HTTP POST.</p>
Python HTTP POST binary file upload with pycurl (Python)
2008-08-14T04:47:36-07:00Robert Lujohttp://code.activestate.com/recipes/users/4044016/http://code.activestate.com/recipes/576422-python-http-post-binary-file-upload-with-pycurl/
<p style="color: grey">
Python
recipe 576422
by <a href="/recipes/users/4044016/">Robert Lujo</a>
(<a href="/recipes/tags/django/">django</a>, <a href="/recipes/tags/http/">http</a>, <a href="/recipes/tags/post/">post</a>, <a href="/recipes/tags/upload/">upload</a>).
</p>
<p>There is a way to upload file with standard python libraries (urllib, httplib, ...) as explained at <a href="http://code.activestate.com/recipes/146306/" rel="nofollow">http://code.activestate.com/recipes/146306/</a>. But that didn't worked for me for binary data. I didn't liked/tried solution explained at <a href="http://fabien.seisen.org/python/urllib2_multipart.html" rel="nofollow">http://fabien.seisen.org/python/urllib2_multipart.html</a>, so I tried with pycurl (<a href="http://pycurl.sourceforge.net/" rel="nofollow">http://pycurl.sourceforge.net/</a> wrapper for <a href="http://curl.haxx.se/libcurl/" rel="nofollow">http://curl.haxx.se/libcurl/</a>) because it is std. lib for php, and uploading the file is very simple (just add @<path-to-file> to post variable value). It was a little hard to find proper way because there is no such example or documentation. But I found it, and it is so simple ;)</p>
<p>I supply django test application which receives file that is uploaded.</p>
Composing a POSTable HTTP request with multipart/form-data Content-Type to simulate a form/file upload. (Python)
2014-03-08T17:34:38-08:00István Pásztorhttp://code.activestate.com/recipes/users/4189380/http://code.activestate.com/recipes/578846-composing-a-postable-http-request-with-multipartfo/
<p style="color: grey">
Python
recipe 578846
by <a href="/recipes/users/4189380/">István Pásztor</a>
(<a href="/recipes/tags/field/">field</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/form/">form</a>, <a href="/recipes/tags/html/">html</a>, <a href="/recipes/tags/httpclient/">httpclient</a>, <a href="/recipes/tags/mime/">mime</a>, <a href="/recipes/tags/multipart/">multipart</a>, <a href="/recipes/tags/post/">post</a>, <a href="/recipes/tags/upload/">upload</a>, <a href="/recipes/tags/web/">web</a>).
Revision 5.
</p>
<p>This code is useful if you are using a http client and you want to simulate a request similar to that of a browser that submits a form containing several input fields (including file upload fields). I've used this with python 2.x.</p>
Wrap a string in a file-like object that calls a user callback whenever read() is called on the stream (Python)
2013-09-22T21:48:03-07:00Ben Hoythttp://code.activestate.com/recipes/users/4170919/http://code.activestate.com/recipes/578669-wrap-a-string-in-a-file-like-object-that-calls-a-u/
<p style="color: grey">
Python
recipe 578669
by <a href="/recipes/users/4170919/">Ben Hoyt</a>
(<a href="/recipes/tags/callback/">callback</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/progress/">progress</a>, <a href="/recipes/tags/upload/">upload</a>).
</p>
<p>Wraps a string in a read-only file-like object, but also calls a user callback with the number of bytes read whenever <code>read()</code> is called on the stream. Used for tracking upload progress, for example for a progress bar in a UI application.</p>
Libgen Epub Upload using Tor (Python)
2015-12-06T19:23:54-08:00fuji239http://code.activestate.com/recipes/users/4193238/http://code.activestate.com/recipes/579134-libgen-epub-upload-using-tor/
<p style="color: grey">
Python
recipe 579134
by <a href="/recipes/users/4193238/">fuji239</a>
(<a href="/recipes/tags/beautifulsoup/">beautifulsoup</a>, <a href="/recipes/tags/libgen/">libgen</a>, <a href="/recipes/tags/mechanize/">mechanize</a>, <a href="/recipes/tags/tor/">tor</a>, <a href="/recipes/tags/upload/">upload</a>).
Revision 2.
</p>
<p>This script shows how to upload epub files in Library Genesys (libgen) automatically by using Tor. Please note that only copyright free epubs should be used (such as those present in <a href="https://www.gutenberg.org/" rel="nofollow">https://www.gutenberg.org/</a>).
It will also check if MD5 hash is present before uploading.
This is provided for python educative purposes only : it shows how to use a Tor proxy, Mechanize (for uploading and form processing), Hashlib for MD5 calculation, Filemagic for mimetype detecting and BeautifulSoup for response analyzing, all together.</p>
Wrap a a file-like object in another that calls a user callback whenever read() is called on it. (Python)
2013-09-25T01:54:53-07:00Martin Millerhttp://code.activestate.com/recipes/users/155538/http://code.activestate.com/recipes/578674-wrap-a-a-file-like-object-in-another-that-calls-a-/
<p style="color: grey">
Python
recipe 578674
by <a href="/recipes/users/155538/">Martin Miller</a>
(<a href="/recipes/tags/callback/">callback</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/oop/">oop</a>, <a href="/recipes/tags/progress/">progress</a>, <a href="/recipes/tags/upload/">upload</a>).
</p>
<p>Wraps a file-like object in another, but also calls a user callback with the number of bytes read whenever its <code>read()</code> method is called. Used for tracking upload progress, for example for a progress bar in a UI application.</p>