openrefine-client/google/urllib2_file/README

33 lines
799 B
Plaintext

Python urllib2_file.py enable you to upload files using HTTP multipart/form-data
Install:
python setup.py test
python setup.py build
python setup.py install
Example:
import urllib2_files
import urllib2
data = { 'foo': 'bar',
'form_name': open("/lib/libc.so.1") }
(send something like: 'Content-Disposition: form-data; name="form_name"; filename="form_name";' )
Or if you want to specify a different filename:
data = {'foo': 'bar',
'form_name': {'fd': open('/lib/libresolv.so.2',
'filename': 'libresolv.so'} }
(send something like: 'Content-Disposition: form-data; name="form_name"; filename="libresolv.so";' )
u = urllib2.urlopen('http://site.com/path/upload.php', data)
Tested with:
python 2.3
python 2.4
python 2.5