title: Upload photo to Tumblr API with nodejs and request module
body: <p>So I want to upload an image to the Tumblr API with the npm request module.
  Being familiar with the facebook and twitter API, those requests worked like this:</p>
  
  <p>for Facebook:<br>
  - create a readstream: var media = fs.createReadStrem('imgpath');<br>
  - make a post request with access data and uri set and:  </p>
  
  <pre><code>options.formData = {
    source: media,
    caption: "test"
  };
  </code></pre>
  
  <p>for Twitter:<br>
   - create readstream<br>
   - upload image to twitter:</p>
  
  <pre><code>options.formData = {
    media: media
  };
  </code></pre>
  
  <p>this works flawlessly.<br>
  But now with Tumblr, I need to encode the image as <strong>"Array (URL-encoded binary contents)"</strong> first.</p>
  
  <p>So my question is. How do I encode it and bring it in the right format for the npm request module. To do this, I first need to load the image with <strong>fs.readFileSync</strong>, but is it possible to upload images to Tumblr as readStream like I did with FB and Twitter?</p>
  
  <p>Here is one of the things I tried:</p>
  
  <pre><code>var img = fs.readFileSync('img');  
  options.form = { 
    type: 'photo',
    data: [img.toString('binary')]
  }  
  </code></pre>
  
  <p>which gives me a 400: Error uploading photo.</p>
  
  <p>I also looked into <a href="https://github.com/arkxu/tumblrwks" rel="nofollow">tumblrwks</a>, which works, but I really want to get this done with <a href="https://github.com/request/request" rel="nofollow">request</a></p>
  
  <p>Thank you! :)</p>