简体   繁体   中英

Sails.js how to convert a base64-encoded to image and store it in disk?

I'm trying to convert the base64-encoded to image but it doesn't work

var base64Data = req.rawBody.split(',')[1];
    require("fs").writeFile("out.png", base64Data, 'base64', function(err){
        if(err){
            console.log('err');
        }

I got it working by request fs

var request = require('fs');

before use in controller

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM