I'm using the Node.JS node-mysql module. One column has a BLOB type and want to read from it and if possible base64 encode it. I haven't been able to find anything on how to do this.
Any ideas?
Try the following snippet:
var buffer = new Buffer( blob );
var bufferBase64 = buffer.toString('base64');
If your blob is binary, use the following instead:
var buffer = new Buffer( blob, 'binary' );
var bufferBase64 = buffer.toString('base64');
You can also simplify that to one line:
var bufferBase64 = new Buffer( blob, 'binary' ).toString('base64');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With