title: How to read BSON data in Express.js with body parser
body: <p>I have a Node.js API using Express.js with body parser which receives a BSON binary file from a python client. </p>
  
  <p>Python client code:</p>
  
  <pre><code>data = bson.BSON.encode({
      "some_meta_data": 12,
      "binary_data": binary_data
  })
  headers = {'content-type': 'application/octet-stream'}
  response = requests.put(endpoint_url, headers=headers, data=data)
  </code></pre>
  
  <p>Now I have an endpoint in my Node.js API where I want to deserialize the BSON data as explained in the documentation: <a href="https://www.npmjs.com/package/bson" rel="nofollow noreferrer">https://www.npmjs.com/package/bson</a>. What I am struggling with is how to get the binary BSON file from the request.</p>
  
  <p>Here is the API endpoint:</p>
  
  <pre><code>exports.updateBinary = function(req, res){
      // How to get the binary data which bson deserializes from the req?
      let bson = new BSON();
      let data = bson.deserialize(???);
      ...
  }
  </code></pre>