Stream files in express request

Asked

Viewed 10 times

0

Iae dev’s. I need a way to get the file stream from the request to send to google drive. I can send the files that are in the server folder, but I wanted to send directly from the request without having to download it on the server and then send it to google drive. I’m using formidable, but I can’t get the file stream. I tried that way without the express:

const server = http.createServer((req, res) => {
  if (req.url === '/api/upload' && req.method.toLowerCase() === 'post') {
    // parse a file upload
    const form = formidable({
      fileWriteStreamHandler: file => uploadStream(file),
    });
    form.parse(req, () => {
      res.writeHead(200);
      res.end();
    });

    return;
  }

as it has in an example on the official formidable github, but it never performs that function. I tried using express-formidable middleware, and also catching straight the _writeStream that comes in the request. But none of the ways did it. Someone gives me a light on how to solve this, or some other middleware. Thanks in advance!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.