Wednesday, June 5, 2024
 Popular · Latest · Hot · Upcoming
167
rated 0 times [  169] [ 2]  / answers: 1 / hits: 31529  / 6 Years ago, mon, august 6, 2018, 12:00:00

I am receiving BLOB data on nodeJs server which is converted from PNG image.



I need to create again png image on nodeJs server to be able to show it on pdf document.



I had tried to use FileSaver on nodeJs but it is not working.
FileSaver works well on reactJs app.



How can I save a new file to the local directory on the server?




There is a lot question pointing on problems with creating an image file
form blob but I was unable to use base64encode, so other questions were
not helpful.



More From » node.js

 Answers
13

In BLOB data of png image file there is buffer property.



So I used this solution to create image.



var imageBuffer = request.file.buffer;
var imageName = 'public/images/map.png';

fs.createWriteStream(imageName).write(imageBuffer);


This has solved my problem.


[#53797] Thursday, August 2, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
montana

Total Points: 675
Total Questions: 86
Total Answers: 102

Location: Mali
Member since Fri, Dec 3, 2021
3 Years ago
;