How to create an image (FileDocument) entity within a microflow

0
Hi have some logic I would like to unit test.   For me to test the logic I have to mock the uploading of an image. I would like to do that via a microflows via a base 64 conversion of a string into a entity that inherits from Image. How would I be able to create that entity object from within a Microflow?   
asked
3 answers
1

i think there is a java action for that in the community commons module. can you try to take a look there?

answered
1

CommunityCommons has a Java action Base64DecodeToFile.

answered
0

Derek,

Depending on the version of Mendix your using you can actually do this without the need for java. If you create a message definition of the image you want to create and a mapping. You can create a json import using a string variable which contains the base 64 code. As long as you match contents to the contents of the file document it'll automatically store this in binary format for you. I use this method all the time now.

 

[
    {
        "Name": "selfie.jpg",
        "Contents":"/9j/4AAQSkZJRgABAQEASABIAAD/4UXERXhpZgAATU0AKgAAAAgACgEOAAIAAAA2AAAIkgEPAAIAAAASAAAIy"
}
]

 

answered