I have small images I want to store as a bin data item. The form is posted but I do not know what to do in the controller so that if I so this, the data is stored. I am using Sails.js and the form is passing data as "image" with the form having a file input type.
var image = new Images;
image.data = ????
image.save();
If the images are smaller than 16Mb, you can save them directly using MongoDB's bindata type. You can always convert the binary stream to a Base64 string, and store it as a string file, but that will reduce the allowed image size.
If the image is larger than 16Mb, you have no choice but to use GridFS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With