title: python dict object has not attribute read
body: <p>I want to get image file from web,and then send to API_Search_Handler which i can not change the code of. Remove the UploadImageHandler i can do that,but I want to use the middle handler to receive call back from API_handler which is image and then show in the web.Can i do that without UploadImageHandler?
  Or how should I fix the error and send correct data type to API_handler? Limit of the code of API_handler is fixed..</p>
  
  <p>index.html</p>
  
  <pre><code>&lt;form action="/uploadimage" enctype="multipart/form-data" method="POST"&gt;
              &lt;p&gt;&lt;input type='file' multiple="true" name="file" id="file"/&gt;&lt;/p&gt;
              &lt;p&gt;&lt;span&gt;:&lt;/span&gt;&lt;input type="int" size="3" value="120" name="dist"/&gt;
              &amp;nbsp&lt;span&gt;:&lt;/span&gt;&lt;input type="int" size="3" value="50" name="max_num" id="max_num" /&gt;&lt;/p&gt;
              &lt;p&gt;&lt;span&gt;：&lt;/span&gt;&lt;/p&gt;
              &lt;p&gt;all:&lt;input type="checkbox" name="dir" value="all" checked&gt;&lt;/p&gt;
              &lt;p&gt;&lt;input type="submit" value="" id="submit" /&gt;&lt;/p&gt;
          &lt;/form&gt;&lt;br/&gt;&lt;br/&gt;
  
  
   class UploadImageHandler(tornado.web.RequestHandler):
          def post(self):
              dist=self.get_body_argument("dist")
              print self.request.body
              max_num=self.get_body_argument("max_num")
              imagedir=self.get_body_argument("dir")
  
              for f in self.request.files['file']:
                  print f['filename']
                  url = 'http://192.168.1.234:8968'
                  files = {'file':{"filename":f["filename"],"body":f["body"]}}
                  data={'dir':imagedir,'dist':dist,'max_num':max_num}
                  requests.post( url + r'/api/search' ,data=data,files = files)
              self.write("save ok")
  </code></pre>
  
  <p>error：</p>
  
  <pre><code>Traceback (most recent call last):
    File "/usr/lib64/python2.7/site-packages/tornado/web.py", line 1346, in _execute
      result = method(*self.path_args, **self.path_kwargs)
    File "/home/zhengminpeng/python-test/web/handlers/index.py", line 24, in post
      requests.post( url + r'/api/search' ,data=data,files = files)
    File "/usr/lib/python2.7/site-packages/requests/api.py", line 108, in post
      return request('post', url, data=data, json=json, **kwargs)
    File "/usr/lib/python2.7/site-packages/requests/api.py", line 50, in request
      response = session.request(method=method, url=url, **kwargs)
    File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 450, in request
      prep = self.prepare_request(req)
    File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 381, in prepare_request
      hooks=merge_hooks(request.hooks, self.hooks),
    File "/usr/lib/python2.7/site-packages/requests/models.py", line 307, in prepare
      self.prepare_body(data, files, json)
    File "/usr/lib/python2.7/site-packages/requests/models.py", line 452, in prepare_body
      (body, content_type) = self._encode_files(files, data)
    File "/usr/lib/python2.7/site-packages/requests/models.py", line 150, in _encode_files
      fdata = fp.read()
  AttributeError: 'dict' object has no attribute 'read'
  </code></pre>
  
  <p>API_Search_Handler</p>
  
  <pre><code>class API_Search_Handler(tornado.web.RequestHandler):
      @tornado.web.asynchronous
      def post(self):
          print 'async search'
          dist = self.get_argument('dist')
          if dist is None:
              dist = 81.0
          num = self.get_argument('max_num')
          if num is None:
              num = 6
          subDir = self.get_argument('dir')
          if subDir == '':
              subDir = 'any'
          logger.info('dist=%s, num=%s' %(dist, num))
  
          for f in self.request.files['file']:
              print f['filename']
              logFile = open(config.LOG_DIR_PATH + 'log_' + str(time.clock())+'_'+f['filename'], 'w')
              logFile.write(f['body'])
              logFile.close()
  
              featureUrl = 'http://' + config.FEATURE_SVR_ADDR+ ':'  + str(config.FEATURE_SVR_PORT)
              featureUrl = featureUrl + featuresvr_urls.SEARCH_FEATURE_HANDLE_URL
              featureUrl = featureUrl + ('?filename=%s&amp;dist=%d&amp;max_num=%d&amp;dir=%s' % (f['filename'], int(dist), int(num), subDir))
  
              def on_response(response):
                  self.write(response.body)
                  self.finish()
              req = tornado.httpclient.HTTPRequest(featureUrl,method='POST', body=f['body'])
  
              http = tornado.httpclient.AsyncHTTPClient()
              http.fetch(req, callback=on_response)
              break
  </code></pre>