openrefine-client/google/urllib2_file
Felix Lohmeier bf91e918df included urllib2_file.py in the package to ease installation 2017-03-14 22:04:06 +01:00
..
LICENSE included urllib2_file.py in the package to ease installation 2017-03-14 22:04:06 +01:00
README included urllib2_file.py in the package to ease installation 2017-03-14 22:04:06 +01:00
__init__.py included urllib2_file.py in the package to ease installation 2017-03-14 22:04:06 +01:00
urllib2_file.py included urllib2_file.py in the package to ease installation 2017-03-14 22:04:06 +01:00

README

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