Storing some small (under 1MB) files with MongoDB in NodeJS WITHOUT GridFS

If your images truly are small enough to not be a problem with document size and you don’t mind a little amount of extra processing, then it’s probably fine to just store it directly in your collection. To do that you’ll want to base64 encode the image, then store it using mongo’s BinData type. As I understand it, that will then save it as a BSON bit array, not actually store the base64 string, so the size won’t grow larger than your original binary image.

It will display in json queries as a base64 string, which you can use to get the binary image back.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)