File Document conversion to Base64

0
Hi Everyone, I am working on a native offline widget where I want to pass the file document object and convert it into base64 format. The prop value for the file document passed is  fileContent: { status: 'available', value: { uri: '/data/user/0/com.mendix.nativetemplate/files/files/default/documents/3377699720528073@1634896530612', name: 'First_File.pdf' } }, How do I convert the file in base64 format with the URI? Is there a way to read the file object metadata to convert the file using file reader?
asked
1 answers
1

Hi Elice,

 

Base64 encoded data can get really large. One option is to do the base64 conversion in the backend using the CommunityCommons Java action.

However, what is your use case to need the contents in base64 encoded format? Quite often you can pass the URI to another library. Only problem is that Mendix stores the files using an internal name, without extension.

I had similar problems when getting my NativeFileDocuments module to work. In that module, I copy the Mendix file to a temporary file with the right name and pass that URI to the native library.

 

With regards,

 

Marcel 

answered