added discord video redirect

pull/12/head
tycrek 3 years ago
parent ead3a5888d
commit b1ad57377d
No known key found for this signature in database
GPG Key ID: 25D74F3943625263

@ -63,6 +63,7 @@ function startup() {
// View file
app.get('/:resourceId', (req, res) => {
let resourceId = req.params.resourceId.split('.')[0];
if (data[resourceId] && data[resourceId].mimetype == 'video/mp4' && req.params.resourceId.split('.')[1] != 'mp4') return res.redirect(req.url + '.mp4');
let fileData = fs.readFileSync(path(data[resourceId].path));
if (data[resourceId]) res.header('Accept-Ranges', 'bytes').header('Content-Length', fileData.byteLength).type(data[resourceId].mimetype).send(fileData);// .sendFile(path(data[resourceId].path));
else res.sendStatus(404);

Loading…
Cancel
Save