How to convert base64 image to file?

Hi Everyone,

I have an image in base64 format, I want to store it on the server. I have used this code for converting it to file, the file gets generated but I can not open image.

**'upload_image', base64data,function(error, result){

**main.js (server)**

	Images.write(new Buffer(base64Data, 'base64'), {
      fileName: 'sample.png',
      type: 'image/png'
    }, function (error, fileRef) {
      if (error) {
        throw error;
      } else {


Can anyone suggest me a way, so that I can display this image to my user?

You should try this.

EDIT: And store the images as a base64 string. BUT if you are thinking about storing a lot of images this way, you should consider something like AWS S3. If its only for an avatar its okay, I guess.

1 Like

Thanks @jhuenges, I have solved this by saving file that created by converting blob to file.

Please show your working code.

Also, did you use a fs library to do this?