title: Trying to post multipart/form-data with node.js supertest
body: <p>I was trying to use Node.js supertest to test some REST API I had written. I need to send a request equivalent to the following CURL request:</p>
  
  <pre><code>curl -X POST -F api_key=KEY -F image=@my_file http://localhost:3000/v1/upload
  </code></pre>
  
  <p>I tried the following, but I got <code>Uncaught TypeError: first argument must be a string or Buffer</code>.</p>
  
  <pre><code>request.post('/v1/upload')
  .type('form')
  .field('api_key', 'abcd')
  .attach('image', 'some path')
  .end(function(err, res) {
    res.body.error.should.equal('Invalid username/api_key.');
    done();
  });
  </code></pre>
  
  <p>I also tried sending it as this:</p>
  
  <pre><code>request.post('/v1/upload')
  .type('form')
  .field('api_key', 'abcd')
  .attach('image', 'some path')
  .end(function(err, res) {
    res.body.error.should.equal('Invalid username/api_key.');
    done();
  });
  </code></pre>
  
  <p>but the server can only parse the file upload request and not the <code>api_key</code>.</p>