Skip to content

Commit

Permalink
allow static server to load files within tools with query parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
benptc committed Jul 14, 2023
1 parent 77bb33a commit c55585c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions controllers/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ function uploadMediaFile(objectID, req, callback) {
// rename uploaded file using mediaUuid that is passed back to client
// let extension = path.extname(filepath);
simplifiedFilename = simplifyFilename(file.originalFilename);
newFilepath = path.join(form.uploadDir, `${mediaUuid}_${simplifiedFilename}`);
// newFilepath = path.join(form.uploadDir, `${mediaUuid}_${simplifiedFilename}`);
newFilepath = path.join(form.uploadDir, simplifiedFilename);
// newFilepath = form.uploadDir + '/' + mediaUuid + extension;

if (fs.existsSync(newFilepath)) {
Expand All @@ -172,7 +173,8 @@ function uploadMediaFile(objectID, req, callback) {
success: true,
mediaUuid: mediaUuid,
rawFilepath: newFilepath,
fileName: `${mediaUuid}_${simplifiedFilename}` // mediaUuid + path.extname(newFilepath)
// fileName: `${mediaUuid}_${simplifiedFilename}` // mediaUuid + path.extname(newFilepath)
fileName: simplifiedFilename // mediaUuid + path.extname(newFilepath)
});
});
}
Expand Down
6 changes: 3 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1571,15 +1571,15 @@ function objectWebServer() {
return;
}
var fileName = path.join(frameLibPath, req.originalUrl.split('/frames/')[1]); //__dirname + '/libraries' + req.originalUrl;

if (!fs.existsSync(fileName)) {
let fileNameWithoutQueryParams = fileName.split('?')[0];
if (!fs.existsSync(fileNameWithoutQueryParams)) {
next();
return;
}

// Non HTML files just get sent normally
if (urlArray[urlArray.length - 1].indexOf('html') === -1) {
res.sendFile(fileName);
res.sendFile(fileNameWithoutQueryParams);
return;
}

Expand Down

0 comments on commit c55585c

Please sign in to comment.