Take picture to Base64- Native app

Hello everyone,  I have a native app where I need to get the System.Image from ‘Take picture’ action and encode it toBase64, in order to pass it to my back-end (similar to this issue ). I tried Javascript action but this didn’t work. Tried calling Microflow (to use Java action) from within my nanoflow, but since my Image entity is persistent, this didn’t work as well. Only thing I didn’t try yet is adapting the Take picture action, but I have no experience with that. Any suggestions, ideas or recommendations are welcome and highly appreciated.   Rali    
2 answers

You can adjust the TakePicture action to return the base64 image data. The TakePictureAdvanced already returns a Mendix object with meta data, usually with base64 processing you also need the dimensions. You can duplicate the JS action and the ImageMetaData entity to your own module and change them. You need an unlimited string attribute for the bas64 data and fill that in the JS action.

Easier approach would be if you could take pictures with the default TakePicture action, synchronize the images to the backend and use CommunityCommons.Base64EncodeFile in a microflow to get the base64 encoded data. Again, you might need the width/height. TakePictureAdvanced returns these as well.


Hi Marcel,

Thank you for the reply! 

So, I tried calling a microflow from a nanoflow and passing the image as parameter, however I get an error because my entity is persistable (because it is System.Image) and it is not allowed on pages accessible through native profile. I have my microflow with the Java action from CommunityCommons but I can’t pass the image to it because of this error. 

I tried using TakePictureAdvanced but all that metadata includes is:


As of the JS action I tried changing it and nothing work I get errors in my phone app and nothing in my Mendix console log. 

Any further help or resources that I can look into?