Answer the question
In order to leave comments, you need to log in
Image file validation in NodeJS?
How to check if the uploaded file is an image (or something else)?
A simple check of the mimetype or extension is done by simply renaming the file.
Here , a colleague recommends checking some "magic numbers". As far as I understand, this is roughly the same as what the file-type module does , which checks
if (check([0xFF, 0xD8, 0xFF])) {
return {
ext: 'jpg',
mime: 'image/jpeg'
};
}
Answer the question
In order to leave comments, you need to log in
Solution "check magic numbers (signatures) before uploading" https://gist.github.com/anonymous/3eb41bad8e9bc7ef... or so https://gist.github.com/anonymous/f8d6fc6544be4e04... if there is something with the file not so, he simply will not write it down anywhere.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question