How to Create a Media content from Java Base64

Enonic version: 6.9.3
OS: Ubuntu

I’m struggling figuring how to create a Media content from a Java Base64 string. I have a Java backend bean that returns a Base64 string. This Base64 is an Excel file to be saved as an media content.

Anyone done something similar ?


To answer my own question.

include ‘com.enonic.lib:text-encoding:1.1.0’

In the code
var encodingLib = require(’/lib/text-encoding’);

var decodedStream = encodingLib.base64Decode( data );