“Base64 NodeJS -Bild” Code-Antworten

Konvertieren Sie Base64 in Bildknotenjs

var base64Data = req.rawBody.replace(/^data:image\/png;base64,/, "");

require("fs").writeFile("out.png", base64Data, 'base64', function(err) {
  console.log(err);
});
Undefined

Nodejs lesen Bild als Basis64

const fs = require('fs');
const contents = fs.readFileSync('/path/to/file.jpg', {encoding: 'base64'});
Clumsy Cicada

Base64 NodeJS -Bild

var fs = require('fs');

// function to encode file data to base64 encoded string
function base64_encode(file) {
    // read binary data
    var bitmap = fs.readFileSync(file);
    // convert binary data to base64 encoded string
    return new Buffer(bitmap).toString('base64');
}
Testy Thrush

Nodejs lesen Bild als Basis64

const fs = require('fs').promises;
const contents = await fs.readFile('/path/to/file.jpg', {encoding: 'base64'});
Clumsy Cicada

Ähnliche Antworten wie “Base64 NodeJS -Bild”

Fragen ähnlich wie “Base64 NodeJS -Bild”

Weitere verwandte Antworten zu “Base64 NodeJS -Bild” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen