Popular recipes tagged "upload" but not "file"http://code.activestate.com/recipes/tags/upload-file/2015-12-06T19:23:54-08:00ActiveState Code RecipesLibgen 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>
Encode 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>