mindee
Version:
Mindee Client Library for Node.js
32 lines (31 loc) • 1.16 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PathInput = void 0;
const inputSource_1 = require("./inputSource");
const localInputSource_1 = require("./localInputSource");
const path_1 = __importDefault(require("path"));
const logger_1 = require("../../logger");
const fs_1 = require("fs");
class PathInput extends localInputSource_1.LocalInputSource {
constructor({ inputPath }) {
super({
inputType: inputSource_1.INPUT_TYPE_PATH,
});
this.fileObject = Buffer.alloc(0);
this.inputPath = inputPath;
this.filename = path_1.default.basename(this.inputPath);
}
async init() {
if (this.initialized) {
return;
}
logger_1.logger.debug(`Loading from path: ${this.inputPath}`);
this.fileObject = Buffer.from(await fs_1.promises.readFile(this.inputPath));
this.mimeType = await this.checkMimetype();
this.initialized = true;
}
}
exports.PathInput = PathInput;