NestJS doesn’t natively support streaming file uploads

Here are two JavaScript scripts: one for the server and one for the client. These scripts facilitate file uploads using streams rather than converting the file into form data. However, since NestJS doesn’t natively support this type of file uploading, how can this be achieved within a NestJS application? What are the other option that I can consider?

server.js

import { createWriteStream } from "node:fs";

import http from "node:http";

function respond(res, code, message) {
  res.writeHead(code, {
    "Content-Type": "text/plain",

    "Content-Length": message.length,
  });

  res.end(message);
}

const server = http.createServer(async (req, res) => {
  if (req.method === "POST") {
    const filename = req.headers["content-disposition"].match(/"(.*)"/)[1];

    const file = createWriteStream(`Received-${filename}`);

    req.pipe(file);

    req.on("end", () => {
      respond(res, 200, "Thanks");
    });
  } else {
    respond(res, 200, "Hi");
  }
});

server.on("error", (err) => {
  console.log(err.stack);
});

server.on("clientError", (err, socket) => {
  if (err.code === "ECONNRESET" || !socket.writable) {
    return;
  }

  socket.end("HTTP/1.1 400 Bad Requestrnrn");
});

server.on("listening", () => {
  console.log("Server started on http://localhost:8080");
});

server.listen(8080);

client.js

import { createReadStream } from "node:fs";

async function upload(filename) {
  const res = await fetch("http://localhost:8080", {
    method: "POST",

    headers: {
      "Content-Disposition": `attachment; filename="${filename}"`,
    },

    duplex: "half",

    body: createReadStream(filename),
  });

  return res.ok;
}

console.log(await upload("TestVideo.mp4"));