Merge pull request #51 from msgmaxim/maxim

Adding existing uncommitted code
This commit is contained in:
Maxim Shishmarev 2020-10-26 14:21:35 +11:00 committed by GitHub
commit 32ece20c65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);
});
}