title: Nodejs Resumable file upload using busboy
body: <p>I am implementing an upload endpoint using express and busboy. The code works like a charm. I am trying to implement the logic of resumable uploads. For eg, if a user is uploading a 10gb or 50gb file, and if their internet disconnects, and next time when they are uploading the same file, it should resume.</p>
  <p>I do understand that I need to implement another endpoint that should tell the client how many bytes has been uploaded so far, so that the client can send the remaining bytes.</p>
  <p>I am not sure how to proceed from here, because the first problem i am facing here is that when the upload happens, express uploads the temp file in the tmp directory of the OS. Is it possible to upload the temp file in my current script directory?</p>
  <p>Following is my upload endpoint code.</p>
  <pre><code>router.post(&quot;/upload&quot;, (req, res, next) =&gt; {
    const busboy = new Busboy({ headers: req.headers });
    req.pipe(busboy);
    busboy.on(&quot;file&quot;, (fieldname, file, filename) =&gt; {
      const filepath = path.join(__dirname, filename);
      var writeStream = fs.createWriteStream(filepath);
  
      file.pipe(writeStream);
      writeStream.on(&quot;close&quot;, () =&gt; {
        res.send(filename);
      });
    });
  });
  </code></pre>