fix: uploader fix

This commit is contained in:
Your Name 2026-08-06 15:43:31 -04:00
parent 5299bd34ee
commit cbbb87cd2e

View file

@ -80,8 +80,13 @@ webPush.setVapidDetails(
async function saveFile(structureId, req, uploadedFile, asset=false) {
const name = uploadedFile.name;
const [mime_type, mime_subtype] = uploadedFile.mimetype.split("/");
const uploadPath = path.join(__dirname, "public", structureId);
const storedPath = path.join(structureId, uploadedFile.name);
// structureId may arrive as a number (route.structure_id is an INTEGER) when
// called from a sandboxed handler via require('files').saveFile — the workshop
// /files route passes a string param, which masked this. path.join demands
// strings, so coerce.
const sid = String(structureId);
const uploadPath = path.join(__dirname, "public", sid);
const storedPath = path.join(sid, uploadedFile.name);
fs.mkdirSync(uploadPath, { recursive: true });