UNPKG

@opengis/fastify-table

Version:

core-plugins

19 lines (18 loc) 757 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 = config.s3) { 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;