Image is stored in Mongo:
const Posts = new Schema({
postImg: {
data: Buffer,
type: Buffer,
contentType: String
}
})
In database document looks like this:
"postImg" : { "$binary" : "/9j/4AAQS.blaBla.long.binary.string.."}
And when image is fetched to the client, it looks like this:
{data: Array(84106) [ 255, 216, 255, … ]
type: "Buffer"}
In this case images should be shown like this:
<img src={`data:image/png;base64,${props.postImg}`} alt="a"/>
But that won't work, alt gets shown. I tried {props.postImg.data}, but still nothing.
Any help?
P.S. I use node and express for server-side, and multer package for image upload