2 ms·
Instead of just validating the extension of the user-uploaded image, you can also determine the image type by looking at the first two bytes of the file. https
by hombre_fatal 7y ago
Instead of just validating the extension of the user-uploaded image, you can also determine the image type by looking at the first two bytes of the file.
https://github.com/sdsykes/fastimage/blob/bad902712c146d9fc84d34f419d31a934e8dc0eb/lib/fastimage.rb#L477-L486 https://github.com/sdsykes/fastimage/blob/bad902712c146d9fc8...
It's also nice to move those database calls into a db.js module. That way you can reuse them. And it cleans up the route handlers to just business logic.
I didn't read enough code to have any more advice.