1
I need to save and recover an image in Base64 through a REST service developed with Nodejs. For this, I have created the following schema on Mongo:
const userSettingsSchema = new Schema(
{
'avatar': { type: Buffer, contentType: String, required: false}
}
);
To persist the image, I sent the code Base64 of the image (https://www.base64-image.de/) in a post request for the service passing in the body of the request the JSON:
{
"avatar": "data:image/jpeg;base64,/9j[...]"
}
When I see it in the bank, the avatar is shown in a binary Buffer format:
The problem is that when I try to recover the image by the GET api, it returns with this binary value, and not as Base64:
What I need to do to get the image in Base64?