fix: uploader fix
This commit is contained in:
parent
5299bd34ee
commit
cbbb87cd2e
1 changed files with 7 additions and 2 deletions
9
index.js
9
index.js
|
|
@ -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 });
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue