UNPKG

mindee

Version:

Mindee Client Library for Node.js

28 lines (27 loc) 1.06 kB
"use strict"; 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() { logger_1.logger.debug(`Loading from: ${this.inputPath}`); this.fileObject = Buffer.from(await fs_1.promises.readFile(this.inputPath)); this.mimeType = await this.checkMimetype(); } } exports.PathInput = PathInput;