How to convert an image taken from camera to base64 in native app (nanoflow)?

0
Hi, In a Mx native app we take a picture and want to convert it to a base64 value to use it in an Api call in a Javascript code. 1 – What is the simplest way to achieve this at the moment (i read that it will be possible in february to call from offline app also microflows)? 2 – Should we develop a custom widget for it or can we just write a javascript code for it? 3 – I was also wondering whether I could do the conversion serverside, but since calling a microflow is not supported yet directly, but possible via workaround, I am wondering how to achieve this by passing an image object to it to receive its results back...found this snippet at the forum but without passing an object;   // BEGIN USER CODE return new Promise(function (resolve, reject) { mx.ui.action(microflowName,picture, { progress: "modal", callback: function(result){ resolve(""); } }); }); // END USER CODE --when trying the abouve the mx ui action was not recognized as an function...so I think then to import extra modules or so for mx ui api? 4 – or should i convert binary to base64, since the binary data is available in the object itself? 5 – or can we get the location/url of the image in the localstorage to use in the base64 javascript code?
asked
1 answers
3

Hi Enzo,

You can take the original Take Picture, this one converts the base 64 into a file image, if you remove that and just let it store it in a object attribute, you dont need to reverse the base 64 conversion

https://github.com/mendix/widgets-resources/blob/master/packages-native/actions/src/camera/TakePicture.ts#L84

Cheers Andries

answered