Hi,
I have stored image with media datatype in MSSQL and on fetching it geting bytes.
If i would like to convert it into base64string for display in html img then.
How would I convert it.
Thanks in Advance.
Hi,
I have stored image with media datatype in MSSQL and on fetching it geting bytes.
If i would like to convert it into base64string for display in html img then.
How would I convert it.
Thanks in Advance.
This is the method I use to encode text into Base64:
function encodeBase64FromText(_sInputString) {
var _oEncoder = Packages.org.apache.commons.codec.binary.Base64,
_oJString = Packages.java.lang.String;
return new _oJString(_oEncoder.encodeBase64(new _oJString(_sInputString).getBytes()));
};
So my guess is that it should work with bytes as well like so:
function encodeBase64FromBytes(_aBytes) {
var _oEncoder = Packages.org.apache.commons.codec.binary.Base64,
_oJString = Packages.java.lang.String;
return new _oJString(_oEncoder.encodeBase64(_aBytes));
};
Hope this helps.