mindee
Version:
Mindee Client Library for Node.js
25 lines (24 loc) • 790 B
JavaScript
import { LocalInputSource } from "./localInputSource.js";
import { INPUT_TYPE_BASE64 } from "./inputSource.js";
import { logger } from "../logger.js";
export class Base64Input extends LocalInputSource {
constructor({ inputString, filename }) {
super({
inputType: INPUT_TYPE_BASE64,
});
this.fileObject = Buffer.alloc(0);
this.filename = filename;
this.inputString = inputString;
}
async init() {
if (this.initialized) {
return;
}
logger.debug("Loading from base64");
this.fileObject = Buffer.from(this.inputString, "base64");
this.mimeType = await this.checkMimetype();
// clear out the string
this.inputString = "";
this.initialized = true;
}
}