multer
multer copied to clipboard
Cannot change encoding.
I want to change the files encode or a way to tell multer to do that.. I followed the documentation that totally not working.. I searched for any clue inside the stroage class iteslf but with no luck.
Thanks in advance, sayeko.
What encoding do you mean? The files are saved as they are received over the wire I think...
I have files that contain hebrew or arabic language and when I saved it with multer I get white square with question marks instead of the text.. its an encoding issue that I can solve on the server side but I dont have an options with multer to change it.
Any help?
Did you ever resolve this? I myself tried to set encoding to ucs2 but that didn't resolve the issue.
hello @occasl @sayeko , I have the same problem here, did you find a way out ?
You can always fork multer and add your encoding functionality or after you upload your files change the encoding by your self in code and create new files from them with the correct encoding.
hope it help you.
I'll need some more information before I can fix this. Could someone supply a wire dump of what gets sent to the server when uploading e.g. a file that contains Hebrew/Arabic language that is being saved incorrectly by Multer?
hello @sayeko : yep, I have found a turnaroud after multer to re-encode/decode data by myself. hello @LinusU : I have a small Uint8Array with latin characters within easy hand, does that help ? [100, 99, 116, 102, 121, 118, 103, 117, 104, 98, 233, 233, 233, 232, 232, 13, 10 ]
With v2 coming out, you should be able to change the encoding of the readable file stream given to you by multer.
@LinusU correct me if I'm wrong here!
this is the code I'm using to solve this issue.
const multer = require('multer')
const fileFilter = (req, file, callback) => {
// fix problem can't save arabic strings
file.originalname = Buffer.from(file.originalname, 'latin1').toString('utf8');
callback(null, true);
};
const upload = multer({ fileFilter });
this works too.
const iconv = require('iconv-lite');
file.originalname = iconv.decode(Buffer.from(file.originalname, 'latin1'), 'utf8');
https://github.com/mscdex/busboy/issues/247