I am importing data into a Mendix application. The data consists of Base64 encoded images. The images are stored in a FileDocument that is XML. I have a small sample file with 2 images that I have loaded into my app. When I use Base64DecodeToFile to store the image contents into a Mendix entity, I received the following error: com.mendix.core.CoreException: com.mendix.modules.microflowengine.MicroflowException: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: java.lang.IllegalArgumentException: Illegal base64 character a at BrothersCRM.ViewPicture (JavaAction : 'Base64 decode to file') Advanced stacktrace: at com.mendix.basis.component.InternalCore.execute(InternalCore.java:568) Caused by: com.mendix.modules.microflowengine.MicroflowException: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: java.lang.IllegalArgumentException: Illegal base64 character a at BrothersCRM.ViewPicture (JavaAction : 'Base64 decode to file') When I copy the base64 content and use one of these websites to convert it to an image, it works without an error: https://codebeautify.org/base64-to-image-converter and https://onlinepngtools.com/convert-base64-to-png The sample file with the xml content can be downloaded here: https://www.filehosting.org/file/details/825674/XMLPicturesSample.xml any ideas how I can get this working? ***EDIT*** I found this posting which solved my problem https://community.mendix.com/link/questions/4293
asked
Mike Kumpf
2 answers
2
Did it for me as well:
replaceAll($vBase64, '(?s)[^A-Za-z0-9+/=]', '')
Thanks Robert Price!
answered
Kees de Kraker
1
I think your Base64 is corrupted. When I download the image from your online decoder example, and re-encode it. It comes out slightly different. When I use this different version, the Base64DecodeToFile works.