I'm migrating one website with java/jsf for Node/Angular but i have the problem for convert blob from firebird database to base64 using node-firebird.
connection.query(query,function(err,rows){
if(err) {
res.json({"Error" : true, "Message" : "Error executing query"});
} else {
var buffer;
var bufferBase64;
for(var i = 0; i < rows.length; i++){
rows[i].image(function(err, name, eventEmitter) {
eventEmitter.on('data', function(chunk) {
buffer = new Buffer(chunk, 'binary').toString('base64');
bufferBase64 += buffer;
});
eventEmitter.on('end', function() {
console.log(bufferBase64); // print base64
});
});
}
res.json(rows);
}
connection.detach();
});
This code from node-firebird generate a invalid base64, but this work using Java.
byte[] encoded = Base64.getEncoder().encode(rs.getBytes("image"));
System.out.println(new String(encoded));
This is a buffers of a image : [function] that returns from the database