Currently I handle image uploads using angular-file-upload and I simply save the image to the server's file system and reference it in the HTML. However, I want to try and store the image directly in the database within the Schema I defined for my blog posts.
var blogSchema = new Schema({
title: String,
author: String,
body: String,
likes: { type: Number, default: 0 },
comments: [{ type: Schema.Types.ObjectId, ref: 'Comment' }],
date: { type: Date, default: Date.now },
imageURL: String // instead of this
image: // store it directly
});
"imageURL: String" stores the path to the image.
I want to make it so that I can just have a field that stores the image itself. I was thinking that I could perhaps just upload the image like I already do, but instead convert the image after it has been uploaded and store it in binary (or some other form) in Mongo. Is this possible?
Thanks!