I know it is possible to save binary files into using MongoDB using the "mongofiles" utility.
Is there any way to store Images into a specified collection, not in db.fs.files?
I want to create an users collection which is using to store user details along with their profile pic like this:
{
"_id" : "USR_1",
"username" : "willsmith123",
"firstname" : "will",
"lastname" : "smith",
"status" : "ACTIVE",
"image" : {
"_id" : ObjectId("558be8062f194d2587000001")
"chunkSize" : 261120,
"uploadDate" : ISODate("2015-06-25T10:20:47.105Z"),
"length" : 25038,
"md5" : "b1d38a0b2ccde6da71fd6ae8fe2f637f",
"filename" : "mylogo.png"
}
}
How can I have a collection like this, which maintain relation between users and their images?
Note:
Database is for data
FileSystem for files
Choice Matters
Use GridFs or else use the below stuff
Instead of saving the embedded document
Just save the reference of the image as below
Use the
imageRef
to get or set the image.