mindee
Version:
Mindee Client Library for Node.js
24 lines (23 loc) • 754 B
JavaScript
import { INPUT_TYPE_BYTES } from "./inputSource.js";
import { LocalInputSource } from "./localInputSource.js";
import { logger } from "../logger.js";
export class BytesInput extends LocalInputSource {
constructor({ inputBytes, filename }) {
super({
inputType: INPUT_TYPE_BYTES,
});
this.fileObject = Buffer.alloc(0);
this.filename = filename;
this.inputBytes = inputBytes;
}
async init() {
if (this.initialized) {
return;
}
logger.debug("Loading from bytes");
this.fileObject = Buffer.from(this.inputBytes);
this.mimeType = await this.checkMimetype();
this.inputBytes = new Uint8Array(0);
this.initialized = true;
}
}