Skip to content Skip to sidebar Skip to footer

Problem In Saving The Image Saving From Url In Nodejs

I'm trying to scrape data from website while scraping it i'm getting error like file 'An error ocured while loading image' while opening image from my server directory.image is sto

Solution 1:

Replace

fs.writeFile(path1, body, {encoding: 'base64'}, function(err){
                  });

With

fs.writeFile(path1, 'data:image/jpeg;base64,' + newBuffer(body).toString('base64'), {encoding: 'base64'}, function(err){
                  });

Solution 2:

This is a deprecation warning (I don't think it's an error yet, but it will be soon).

You just need to change the way you call Buffer. Instead of instantiating it directly use the static from method.

new Buffer(body)  // Old
Buffer.from(body) // New

Post a Comment for "Problem In Saving The Image Saving From Url In Nodejs"