I am new to Node Js. I need to include a profile image for users. I get request of image in base64 from IOS app. I need to store it in images folder and save the image path in mongodb database.
I have used the following code,
var bitmap = new Buffer(req.body.profile_image, 'base64');
// write buffer to file
fs.writeFileSync("images/example.jpg", bitmap);
where req.body.profile_image is a base64 image.
I am getting the following error,
TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
req.body.profile_image value will be,
+MZScHeJQ9Cz5dfxnEmIMHWMZyZYnYx8Rrhj0HbtfGUanv5w3UHUyADbiGsKJxeM1yV4uGwBS7cYlAec1w0AX6xg2A1O854UF8OS6PAP1MtzkeFnrNlD41U8XFeGrp1fn3jRMUs8sqS61umSS2rR2NDhppjZ4OvnOWBAq6X+sQNkhKkfZOdYsZOpz8fWIQb6wQ/GchVCgfZko4PMDg1DSumausG6o+2E6wKLLjKReUaHEQXKJV8h85XEKN4p/WEBvTHmmJ/IN178YJVgrGmfOScAuBPp+sggGA7/wC1kgbDiacbGABOcCLHVRpMuBQh5Xn4xqARF03pwkJT23LhxGLiSGp8mCVWDrzPf3iwp4C3nDSg2VUfNwgDvm6vrIiFJvp8ZHIdjoFx8BX0OH0+8TVii3GAKKc2kjz7dYqUCdsuMOm2hrr+h//Z
Please help.