How to use the node-base64-image.decode function in node-base64-image

To help you get started, we’ve selected a few node-base64-image examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rohansapre / cleanhood / Web / server / services / event.service.server.js View on Github external
function uploadImage(req, res) {
        var eid = req.body.eid;
        var image = req.body.eImage;
        eid = eid.replace(/['"]+/g, '');
        var imageName = eid;
        console.log(imageName);
        var imageBuffer = new Buffer(image, 'base64');
        var options = {
            filename: __dirname + '/../../public/uploads/' + imageName
        };
        base64.decode(imageBuffer, options, function (err, success) {
            if(err) {
                res.sendStatus(500).send(err);
            }
            else {
                console.log(success);
                var url = '/Web/public/uploads/' + imageName + '.jpg';
                EventModel
                    .updateInitialPicture(eid, url)
                    .then(function (event) {
                        res.json(url);
                    }, function (error) {
                        res.sendStatus(500).send(error);
                    });
            }
        });
    }

node-base64-image

Download images from remote URLs and encode/decode them to base64

MIT
Latest version published 3 months ago

Package Health Score

72 / 100
Full package analysis