javascript - Reading hex data from createReadStream -
my goal make code detect image in stream, , reject upload of not image. so thread talks functionality might need. having problem getting 'hex' values out of stream i have code: imagestream = fs.createreadstream(tmpfile); i this: let filesignature = imagestream.tostring('hex',0,4); so use these magic number signatures: var magic = { jpg: 'ffd8ffe0', png: '89504e47', gif: '47494638' }; in filesignature getting object, while expect first couple of hex values.