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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -