diff --git a/controllers/object.js b/controllers/object.js index e0a541c3c..ee05c4ae7 100644 --- a/controllers/object.js +++ b/controllers/object.js @@ -128,8 +128,8 @@ function uploadMediaFile(objectID, req, callback) { let form = new formidable.IncomingForm({ uploadDir: mediaDir, - keepExtensions: true - // accept: 'image/jpeg' // TODO: specify which types of images/videos it accepts? + keepExtensions: true, + // accept: 'image/jpeg' // we don't include this anymore, because any filetype can be uploaded }); console.log('created form'); @@ -138,27 +138,23 @@ function uploadMediaFile(objectID, req, callback) { callback(500, err); }); - let mediaUuid = utilities.uuidTime(); + let mediaUuid = utilities.uuidTime(); // deprecated let simplifiedFilename = null; let newFilepath = null; form.on('fileBegin', function (name, file) { console.log('fileBegin loading', name, file); - let filepath = file.path || file.filepath; - // rename uploaded file using mediaUuid that is passed back to client - // let extension = path.extname(filepath); + // simplify the filename so that it only contains alphanumeric, hyphens, underscores, and periods simplifiedFilename = simplifyFilename(file.originalFilename); - // newFilepath = path.join(form.uploadDir, `${mediaUuid}_${simplifiedFilename}`); newFilepath = path.join(form.uploadDir, simplifiedFilename); - // newFilepath = form.uploadDir + '/' + mediaUuid + extension; if (fs.existsSync(newFilepath)) { console.log('deleted old raw file'); fs.unlinkSync(newFilepath); } - console.log('upload ' + filepath + ' to ' + newFilepath); + // old formidable library uses file.path, new version uses file.filepath if (file.path) { file.path = newFilepath; } else if (file.filepath) { @@ -171,10 +167,9 @@ function uploadMediaFile(objectID, req, callback) { callback(200, { success: true, - mediaUuid: mediaUuid, - rawFilepath: newFilepath, - // fileName: `${mediaUuid}_${simplifiedFilename}` // mediaUuid + path.extname(newFilepath) - fileName: simplifiedFilename // mediaUuid + path.extname(newFilepath) + mediaUuid: mediaUuid, // deprecated field + fileName: simplifiedFilename, // the "title" of the file + rawFilepath: newFilepath // this is the actual path to the resource }); }); } diff --git a/libraries/objectDefaultFiles/object.js b/libraries/objectDefaultFiles/object.js index ad243248a..65052c251 100755 --- a/libraries/objectDefaultFiles/object.js +++ b/libraries/objectDefaultFiles/object.js @@ -682,7 +682,6 @@ this.setFullScreenOff = makeSendStub('setFullScreenOff'); this.setStickyFullScreenOn = makeSendStub('setStickyFullScreenOn'); this.setStickinessOff = makeSendStub('setStickinessOff'); - this.setFull2D = makeSendStub('setFull2D'); this.setExclusiveFullScreenOn = makeSendStub('setExclusiveFullScreenOn'); this.setExclusiveFullScreenOff = makeSendStub('setExclusiveFullScreenOff'); this.isExclusiveFullScreenOccupied = makeSendStub('isExclusiveFullScreenOccupied'); @@ -1387,16 +1386,6 @@ postDataToParent(dataToPost); }; - /** - * Removes or adds the touch overlay div from the tool, without affecting fullscreen status - * @param {boolean} enabled - */ - this.setFull2D = function (enabled) { - postDataToParent({ - full2D: enabled - }); - } - this.setStickyFullScreenOn = function (params) { spatialObject.sendFullScreen = 'sticky'; // console.log(spatialObject.frame + ' fullscreen = ' + spatialObject.sendFullScreen); diff --git a/server.js b/server.js index 99e8016e2..db1f916bb 100644 --- a/server.js +++ b/server.js @@ -1571,6 +1571,7 @@ function objectWebServer() { return; } var fileName = path.join(frameLibPath, req.originalUrl.split('/frames/')[1]); //__dirname + '/libraries' + req.originalUrl; + // we need to check without any ?options=xyz at the end or it might not find the file let fileNameWithoutQueryParams = fileName.split('?')[0]; if (!fs.existsSync(fileNameWithoutQueryParams)) { next(); @@ -1584,7 +1585,7 @@ function objectWebServer() { } // HTML files get object.js injected - var html = fs.readFileSync(fileName, 'utf8'); + var html = fs.readFileSync(fileNameWithoutQueryParams, 'utf8'); // remove any hard-coded references to object.js (or object-frames.js) and pep.min.js html = html.replace('', '');