Node.js upload file to buffer instead of / tmp

In the Node.js application, is it possible to upload the file ( multipart/form-data) directly to the buffer on the server instead of saving the file to the file system?

In psuedo code, you usually do this with a file upload form

router.post('/upload', function(req, res, next){
  // file is saved to /tmp/dk3idkalel4kidkek
  // do some processing on the file
  // manually save file to /www/myapp/uploads/originafilename.ext
});

Is it possible to skip the part of saving the file to /tmpand just grab the downloaded file as a buffer and transfer it directly to the target directory?

An example would be to download an image, then optimize the image, and then save it to the designated destination. Can you just capture the incoming stream, optimize it, and then save it, without first saving to the directory /tmp?

+4
source share
2

Multer node.js multipart/form, . . , , .

, .

+2

Multer busboy , busboy : connect-busboy

+1

Source: https://habr.com/ru/post/1621353/


All Articles