Adding existing uncommitted code

This commit is contained in:
Maxim Shishmarev 2020-10-26 14:19:50 +11:00
parent e9b7a37c62
commit 3ec1799c18
1 changed files with 8 additions and 0 deletions

View File

@ -80,4 +80,12 @@ module.exports = (app, prefix) => {
});
app.use(prefix + '/f', express.static(fileUploadPath));
app.use(prefix + '/loki/v1/f/:file', function(req, res) {
const safePath = req.params.file.replace(/[\.\/]/g, '');
const buf = fs.readFileSync('files/' + safePath);
res.type('application/octet-stream');
res.setHeader("Access-Control-Allow-Origin", "*");
res.end(buf);
});
}