Mobile app client side binary to base64 conversion

Mobile app client side binary to base64 conversion

  

Hi,

In our mobile app we have local entity with binary field. We want to use this image as base64 string for google maps marker. 

I've tried btoa($parameters.image) but result string is not a valid base64 image. Also I've tried

var reader = new FileReader();
  binarystring = reader.readAsBinaryString($parameters.image);
$parameters.base64 = btoa(binarystring);

but that doesn't recognize  $parameters.image as blob.

While viewing data on developers tools it seems that data is actually stored as base64 string... But I can't assign the value directly to my icon as it requires text instead of binary.... 

I would appreciate any suggestion of how to work this out.

Thank. you.

Hi,

Checks if this component solves your issue:

https://www.outsystems.com/forge/component/287/extension-base64/

If not try to do with extension (C#):

using (Image image = Image.FromFile(Path))
{
    using (MemoryStream m = new MemoryStream())
    {
        image.Save(m, image.RawFormat);
        byte[] imageBytes = m.ToArray();

        // Convert byte[] to Base64 String
        string base64String = Convert.ToBase64String(imageBytes);
        return base64String;
    }
}



Hi, This component is working fine but on server side. 

For our purposes we need client side conversion. However it might be a solution - assign binary value to text inside JS Node as binary field in local storage is actually a base64 string.

Hi Mykola,


Did you already try just doing $parameters.base64 = $parameters.image  ?


Edit: oops looks like I took too long writing the reply, yeah is like you said :P


Regards,
João Rosado