Can anybody help me with implementing a JavaScript action that takes a FileDocument object as input, and returns the Base64 representation of the contents? I asked GPT and I learned about the btoa() function which turns a binary string to a base64 string, but then I got stuck when it suggested to implement a FileReader to get the binary content, and I couldn't find another way to get the binary contents from the provided file parameter.
asked
Martin Leppen
2 answers
2
If you're doing that in a native app, NativeFileDocuments allows you to do just that using the readFile JS action
answered
Marcel Groeneweg
1
The FileReader is definitely the right suggestion. For implementation of the FileReader, I think this thread on stackoverflow has some great examples and explanations (better than the mdn web docs).
Used this for another project outside of Mendix which worked great.