title: Upload files in nodejs to another service
body: <p>how do i send a local photo file to a rest api?
  I have a service entirely in nodeJS that receives messages and sends, however, I would like to be able to do the same for other files. I can download the files and store them in an image folder, but I don't know how to get that same image and send it to another server</p>
  <p>The download function takes a download url (https:example.com/id=123/file.jpg/123321) and file name (file.jpg) and downloads the file to the requested folder.</p>
  <pre class="lang-js prettyprint-override"><code>const fs = require(&quot;fs&quot;);
  const http = require(&quot;http&quot;);
  
  //download function
  let download = async (url, fileName) =&gt; {
    const file = fs.createWriteStream(`./src/temp/${fileName}`);
    const request = https.get(url, function (response) {
      response.pipe(file);
  
      file.on(&quot;finish&quot;, () =&gt; {
        file.close();
        console.log(&quot;Download Completed&quot;);
      });
    });
  };
  
  //POST function
  let controllerMessage = async (received_message, user, type, res) =&gt; {
    var body = {
      body: received_message,
      user: user,
      type: type,
    };
    try {
      await axios.post(URL_SERVER, body).then(async (response) =&gt; {
        sendMessage(response.data);
      });
    } catch (e) {}
  };
  </code></pre>
  <p>I need to get this file and send it to another server</p>