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.


Comments

Popular posts from this blog

python - Best design pattern for collection of objects -

go - serving up pdfs using golang -

python - django admin: changing the way a field (w/ relationship to another model) is submitted on a form so that it can be submitted multiple times -