How to use oc-storage-adapters-utils - 1 common examples

To help you get started, we’ve selected a few oc-storage-adapters-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github opencomponents / oc / src / registry / routes / static-redirector.js View on Github external
req.params[0];
    }

    if (!fs.existsSync(filePath)) {
      res.errorDetails = `File ${filePath} not found`;
      return res.status(404).json({ err: res.errorDetails });
    }
    
    const stats = fs.statSync(filePath);
    if (stats.isDirectory()) {
      res.errorDetails = 'Forbidden: Directory Listing Denied';
      return res.status(403).json({ err: res.errorDetails });
    }

    const fileStream = fs.createReadStream(filePath),
      fileInfo = getFileInfo(filePath);

    if (fileInfo.mimeType) {
      res.set('Content-Type', fileInfo.mimeType);
    }

    if (fileInfo.gzip) {
      res.set('Content-Encoding', 'gzip');
    }

    fileStream.on('open', () => {
      fileStream.pipe(res);
    });
  };
};

oc-storage-adapters-utils

Common storage adapter utils for OC

MIT
Latest version published 2 years ago

Package Health Score

46 / 100
Full package analysis

Popular oc-storage-adapters-utils functions