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.
Configs for this Auto Step
- conf_file
- A: Converted files (1 file fixed, less than 10MB) *
- conf_base64String
- B: String after Base64 conversion (updated) *
Script (click to open)
main();
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 );
}
Download
- Converter-File-to-Base64String.xml
- 2023-02-01 (C) Questetra, Inc. (MIT License)
(Installation of add-on automated processes is only available in the Professional edition)
Notes
- 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.
Capture
