Convert bytes[] to base64String in servoy

Forum to discuss the new web client version of Servoy.

Convert bytes[] to base64String in servoy

Postby Rakesh.Sharma » Mon Jan 22, 2018 11:17 am


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.
Posts: 8
Joined: Mon May 29, 2017 8:13 am

Re: Convert bytes[] to base64String in servoy

Postby ROCLASI » Mon Jan 22, 2018 11:32 am

This is the method I use to encode text into Base64:

Code: Select all
function encodeBase64FromText(_sInputString) {
   var _oEncoder =,
       _oJString =;
   return new _oJString(_oEncoder.encodeBase64(new _oJString(_sInputString).getBytes()));

So my guess is that it should work with bytes as well like so:

Code: Select all
function encodeBase64FromBytes(_aBytes) {
   var _oEncoder =,
       _oJString =;
   return new _oJString(_oEncoder.encodeBase64(_aBytes));

Hope this helps.
Robert Ivens
ROCLASI Software Solutions / JBS Group, Partner
SAN Developer / Servoy Valued Professional / Servoy Certified Developer
Twitter: @roclasi / @servoyforge
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
Servoy Expert
Posts: 5285
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 3 guests