1

I check many questions and find first answer here - NodeJS: Saving a base64-encoded image to disk, it's nice and I can save img to disk. But, I see this topic How to do Base64 encoding in node.js? and have this question: can I send image to the third service without saving img to disk? I have this code, it's doesn't work

    var url = req.body.upload_url;
    var img = req.body.img;
    var base64Data = img.replace(/^data:image\/png;base64,/,"");
    var tempIMG = new Buffer(base64Data, 'base64');

    curl(url, {
        MULTIPART: [

            {name: 'file1', file: tempIMG, type: 'image/png'},
            {name: 'sumbit', contents: 'send'}
        ]
    }, function(e) {
        log.info(this.body);
        res.json(this.body);
    });

I rly need to save img to the disk -> send to the servise -> delete img ? or I can use buffer, but there is mistake? If I send test file from disk - this code work.

Community
  • 1
  • 1
Max P
  • 1,439
  • 3
  • 15
  • 33

0 Answers0