Skip to content

Commit

Permalink
update /virtualizer_recording API to serve files from the new correct…
Browse files Browse the repository at this point in the history
… directory structure
  • Loading branch information
benptc committed Jan 28, 2022
1 parent f6d64e9 commit e05bd50
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1518,20 +1518,24 @@ function objectWebServer() {
res.sendFile(fileName);
});

webServer.use('/virtualizer_recording/:filename', function (req, res) {
const range = req.headers.range;
if (!range) {
res.status(400).send('Requires Range header');
return;
}

const videoPath = path.join(objectsPath, identityFolderName, 'virtualizer_recordings', req.params.filename);
webServer.use('/virtualizer_recording/:deviceId/:colorOrDepth/:filename', function (req, res) {
let deviceId = req.params.deviceId;
let videoType = req.params.colorOrDepth;
let filename = req.params.filename;
const videoPath = path.join(objectsPath, identityFolderName, 'virtualizer_recordings', deviceId, 'session_videos', videoType, filename);

if (!fs.existsSync(videoPath)) {
res.status(404).send('No video at path: ' + videoPath);
return;
}

const range = req.headers.range;
if (!range) {
// res.status(400).send('Requires Range header');
res.sendFile(videoPath);
return;
}

const videoSize = fs.statSync(videoPath).size;
// console.log('Video Size = ' + Math.round(videoSize / 1000) + 'kb');

Expand Down

0 comments on commit e05bd50

Please sign in to comment.