title: Flask server cannot read file uploaded by POST request
body: <p>I have my React client post a file with the fetch api to the '/dataset' endpoint.</p>
  
  <pre><code>import 'whatwg-fetch';
  
  uploadData(csv) {
      this.dataset = csv;
  
      fetch('/dataset', {
          method: 'POST',
          body: this._fileToFormData(csv)
      }).then(
          (response) =&gt; {
              console.log(response);
          }
      ).catch( () =&gt; {} );
  };
  
  _fileToFormData(file) {
          var formData = new FormData();
          formData.append('file', file);
          return formData
      };
  </code></pre>
  
  <p>My Flask server is supposed to pick it up.</p>
  
  <pre><code>@app.route('/dataset', methods=['POST'])
  def dataset():
      print request.get_data()
      csv_data = request.form['file']
      print csv_data
      return '{ "fake_json":100}', 200
  </code></pre>
  
  <p>However, the <code>csv_data</code> object is simply a unicode string, <code>'[object File]'</code></p>
  
  <p>The code </p>
  
  <pre><code>print "form:", request.form
  print "files:", request.files
  </code></pre>
  
  <p>returns </p>
  
  <pre><code>ImmutableMultiDict([('file', u'[object File]')])
  ImmutableMultiDict([])
  </code></pre>
  
  <p>How do I get the actual contents of the CSV file? </p>
  
  <p>=== EDIT: Solved ===</p>
  
  <p>the variable csv was actually a single file array, so I needed to extract the file out. </p>