def _get_file_info(ctx):
 retval = []
 request = ctx.transport.req
 headers = request.getAllHeaders()
 content_type = headers.get('content-type', None)
 if (content_type is None):
  return retval
 img = cgi.FieldStorage(fp=request.content, headers=ctx.in_header_doc, environ={'REQUEST_METHOD': request.method, 'CONTENT_TYPE': content_type})
 try:
  keys = img.keys()
 except TypeError:
  return retval
 for k in keys:
  field = img[k]
  file_type = field.type
  file_name = field.disposition_options.get('filename', None)
  if (file_name is not None):
   retval.append(_FileInfo(k, file_name, file_type, [mmap(field.file.fileno(), 0)]))
 return retval

def _get_file_info ( ctx ) : retval = [ ] request = ctx . transport . req headers = request . getAllHeaders ( ) content_type = headers . get ( 'content-type' , None ) if ( content_type is None ) : return retval img = cgi . FieldStorage ( fp = request . content , headers = ctx . in_header_doc , environ = { 'REQUEST_METHOD' : request . method , 'CONTENT_TYPE' : content_type } ) try : keys = img . keys ( ) except TypeError : return retval for k in keys : field = img [ k ] file_type = field . type file_name = field . disposition_options . get ( 'filename' , None ) if ( file_name is not None ) : retval . append ( _FileInfo ( k , file_name , file_type , [ mmap ( field . file . fileno ( ) , 0 ) ] ) ) return retval
we need this hack because twisted doesnt offer a way to get file name from content-disposition header .