Package echonest :: Package web :: Module urllib2_file
[hide private]
[frames] | no frames]

Module urllib2_file

source code


enable to upload files using multipart/form-data

idea from:
upload files in python:
 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306

timeoutsocket.py: overriding Python socket API:
 http://www.timo-tasi.org/python/timeoutsocket.py
 http://mail.python.org/pipermail/python-announce-list/2001-December/001095.html

import urllib2_files
import urllib2
u = urllib2.urlopen('http://site.com/path' [, data])

data can be a mapping object or a sequence of two-elements tuples
(like in original urllib2.urlopen())
varname still need to be a string and
value can be string of a file object
eg:
  ((varname, value),
   (varname2, value),
  )
  or
  { name:  value,
    name2: value2
  }

Classes [hide private]
  newHTTPHandler
  newHTTPSHandler
Functions [hide private]
 
get_content_type(filename) source code
 
send_data(v_vars, v_files, boundary, sock=None) source code
Variables [hide private]
  CHUNK_SIZE = 65536