title: Send uploaded file from one sever to third party api in nodejs
body: <p>I have to integrate a third-party API for uploading the documents but file uploading will be done on our server and from there I want to send the uploaded file to their api(third party). File type is binary.</p>
  <p>I have to achieve this by form-data without uploading the file temporarily.</p>
  <p>I was trying this code :</p>
  <pre><code>const express = require(&quot;express&quot;);
  const multer = require(&quot;multer&quot;);
  const helmet = require(&quot;helmet&quot;);
  const bodyParser = require(&quot;body-parser&quot;);
  var FormData = require(&quot;form-data&quot;);
  const axios = require('axios');
  
  const upload = multer({ storage: storage });
  
  const app = express();
  
  app.use(express.json());
  app.use(express.urlencoded({ extended: true }));
  app.use(bodyParser.raw({ limit: &quot;50mb&quot;, type: [&quot;image/*&quot;] }));
  
  app.post(&quot;/upload&quot;, multer().single(&quot;file1&quot;), async (req, res) =&gt; {
    var form = new FormData();
    
    let file_data = req.file;
  //   let base64String = file_data.data.toString('binary');
  
    form.append(&quot;MID&quot;, &quot;M001590&quot;);
    form.append(&quot;Timestamp&quot;, &quot;2019-06-24&quot;);
    form.append(&quot;DocumentType&quot;, &quot;Passport&quot;);
    form.append(&quot;InvestorId&quot;, &quot;373916&quot;);
    form.append(&quot;Checksum&quot;, &quot;7677c50e9d7588312c4179acd64c447d6144bb92bc51f8f7a08119d6f79ce278&quot;);
    form.append(&quot;File&quot;, req.file); //This is the file in binary format that we got from req.file
  
    // console.log(form);
  
    let investorExist_response = await axios.post(
      &lt;here third-party api will come&gt;,
      form,
      {
        headers: {
          // &quot;Content-Type&quot;: &quot;multipart/form-data&quot;,
          &quot;Content-Type&quot;: &quot;application/x-www-form-urlencoded&quot;
        },
      }
    );
    
    console.log(investorExist_response.data);
    res.send(&quot;done&quot;);
  });
  
  app.listen(3000, () =&gt; {
    console.log(&quot;Server is running at PORT : 3000&quot;);
  });
  </code></pre>
  <p>While hitting the third-party api directly on postman after uploading the file, it is working fine.
  Please tell me the way to directly pass the file on their server so that we don't need to save the file temporary. Is it needed to convert the file in to binary?</p>
  <p>Thanks in advance.</p>