UNPKG

burdy

Version:

Open Source Headless Platform

36 lines (35 loc) 1.68 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const aws_s3_driver_1 = __importDefault(require("./aws-s3-driver")); const file_system_driver_1 = __importDefault(require("./file-system-driver")); class FileDriver { constructor() { this.getUpload = () => this.implementation.getUpload(); this.getPath = (key) => this.implementation.getPath(key); this.getName = () => this.implementation.getName(); this.copy = (src, dest) => this.implementation.copy(src, dest); this.write = (key, content) => this.implementation.write(key, content); this.read = (key) => this.implementation.read(key); this.stat = (key) => this.implementation.stat(key); this.delete = (params) => this.implementation.delete(params); this.createReadStream = (key, options) => this.implementation.createReadStream(key, options); this.createWriteStream = (key, options) => this.implementation.createWriteStream(key, options); this.uploadReadableStream = (key, stream) => this.implementation.uploadReadableStream(key, stream); if (process.env.FILE_DRIVER === 'aws_s3') { this.implementation = new aws_s3_driver_1.default(); } else { this.implementation = new file_system_driver_1.default(); } } static getInstance() { if (!FileDriver.instance) { FileDriver.instance = new FileDriver(); } return FileDriver.instance; } } exports.default = FileDriver;