Writing binary data using node.js fs.writeFile to create an image file

前端 未结 4 647
渐次进展
渐次进展 2020-12-02 17:46

I\'m trying to write a canvas data with node.js fs.writeFile as a binary. JPEG file, but after the file is written I can see that the file is stored as plain text, not binar

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 18:27

    I have had the question in question. I solved the problem when I made the default value null of "encoding" in the "request" library

    var request = require("request").defaults({ encoding: null });
    var fs = require("fs");
    
    fs.writeFile("./image.png", body, function(err) {
        if (err) throw err;
    });
    

提交回复
热议问题