Converter (File to Base64String)

Converter: File to Base64String

Converts file type data to Base 64 encoded string type data. If there are multiple files in File-type data, or if the file size exceeds 10 MB the data will not be converted.

Auto Step icon
Configs for this Auto Step
A: Converted files (1 file fixed, less than 10MB) *
B: String after Base64 conversion (updated) *
Script (click to open)

function main(){
//// == Config Retrieving ==
const dataId_file         = configs.get( "conf_file" );
const dataId_base64String = configs.get( "conf_base64String" );

//// == Calculating ==
const files = engine.findDataByNumber( dataId_file );
let text = "";

if (files.size() != 1) {
  throw `File count invalid.`;

const file = files.get(0);

if (file.getLength() > 10485760) {
  throw `File size over.`;

fileRepository.readFile(file, 3145728, function(bytes) {
  text += base64.encodeToString(bytes);

engine.setDataByNumber( dataId_base64String, text );



warning This is freely-modifiable JavaScript (ECMAScript) code. No warranty of any kind.
(Installation of add-on automated processes is only available in the Professional edition)


  • An error occurs if there are zero or more than two files included in the File-type data. An error is generated if the file size exceeds 10MB.


See Also