Answer the question
In order to leave comments, you need to log in
NodeJS How to write data received from busboy to Buffer?
Good evening.
I use busboy to get data (pictures).
I get data like this:
var buffer = Buffer.allocUnsafe(filesize);
req.recvSize = 0;
file.on('data', function (data) {
buffer.write(data,req.recvSize,data.length);
req.recvSize += data.length;
});
Answer the question
In order to leave comments, you need to log in
you can use Buffer.copy instead of write.
https://nodejs.org/dist/latest-v6.x/docs/api/buffe...
or switch file-stream to the mode when it will send utf8 strings through the "data" event.
https://nodejs.org/dist/latest-v6.x/docs/api/strea...
Upd: It's a bad idea to read utf8 cards in strings. so -> buffer.copy()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question