title: How to save a file sent from NodeJS with POST
body: <p>I created the following function to load a stream file. This stream is sent to the address specified with a POST. At the destination, I have another NodeJS service that with ExpressJS &quot;capture&quot; this POST but I have no idea how I can save the file to the destination.</p>
  <p>NodeJS on my PC:</p>
  <pre><code>function sendFileToRaspberry(filePath) {
      var options = {
          method: 'POST',
          url: 'http://x.x.x.x:8080/api/print',
          qs: {file: fs.createReadStream(filePath)},
          headers:
              {
                  'cache-control': 'no-cache'
              }
      };
  
      request(options, function (error, response, body) {
          if (error) throw new Error(error);
  
          console.log(body);
      });
  }
  </code></pre>
  <p>NodeJS on my Raspberry:</p>
  <pre><code>app.post('/api/print', function (req, res) {
  
      ORIGINAL_IP = req.ip.replace(&quot;::ffff:&quot;, '');
      console.log(&quot;Received a print request from: &quot; + ORIGINAL_IP);
  
      // Test history data for /api/printer API
      var file = req.query.file;
      console.log(&quot;Test data: &quot; + file);
      util.inspect(file);
  
  });
  </code></pre>
  <p>But in the console log I get:</p>
  <blockquote>
  <p>Received a print request from: y.y.y.y</p>
  <p>Test data: [object Object]</p>
  </blockquote>
  <p>How can I save this file on Rasp?</p>