UNPKG

@opengis/fastify-table

Version:

core-plugins

24 lines (18 loc) 749 B
import path from 'node:path'; import config from '../../../../../../../config.js'; function getPath(fp, s3Settings) { const filepath = fp.replace(/\\/g, '/'); if (s3Settings.folder && !filepath.includes(s3Settings.folder)) { return path.join(s3Settings.folder, fp.startsWith('files') ? '' : 'files', filepath); } return filepath; } function getS3FilePath(fp, s3Settings) { const filepath = getPath(fp, s3Settings); const unixPath = filepath.replace(/\\/g, '/').split('work/').pop(); const prefix = !filepath.includes(config.folder) ? config.folder : ''; const sufix = unixPath[0] === '/' ? '' : '/'; const s3FilePath = prefix + sufix + unixPath; return s3FilePath; } export default getS3FilePath;