title: How do I post a plain file buffer instead of binary-encoded-file when posting with nodejs/npm's request package?
body: <p>I am using npm's request package to do a post of a file-buffer to a REST api written using meteor.js restivus package. My node.js client code that posts to the api is as follows:</p>
  
  <p><pre>
      url = '<a href="http://localhost:3000/api/v1/images/" rel="nofollow noreferrer">http://localhost:3000/api/v1/images/</a>';</p>
  
  <code>fs.readFile('./Statement.odt', function read(err, data) {
      if (err) {
          throw err;
      }
      console.log(data);  //At this stage the file is still a buffer - which is correct
      var file = data;
  
      request.post({
        uri: url, 
        headers:   {
          'X-User-Id': userId,
          'X-Auth-Token': authToken
        },
        form: {
            file: file, //Inside the request.post the file is converted to binary encoding
            name:"Statement.odt"
        }
      }, function(err, httpResponse, body) {
        if (err) {
          return console.error('post failed:', err);
        }
  
        console.log('Get successful!  Server responded with:', body);
      });
  });
  </code></pre>
  
  <p></p>
  
  <p>The problem/issue here is that inside the request.post the file is converted to binary-encoded blob. See my comments in the "form:" property of the first argument of "request.post" in the code above. This becomes a problem on my meteor.js server where the file is required as a buffer instead of a binary encoded file. (For info: I am using Ostr-io/files' GridFS  to store the file - it requires the file to be a buffer) </p>
  
  <p>If there is no way other than to pass the file as an encoded string, then is there a way to convert that encoded blob back to a buffer server-side where I am using/talking meteor.js?
  Please help!</p>
  
  <p>If you need more info, please let me know, I'll provide.</p>