diff --git a/index.js b/index.js index 8439d51..96f19da 100644 --- a/index.js +++ b/index.js @@ -52,36 +52,6 @@ app.get('/file/:filename', (req, res) => { return; } - fs.access(filePath, fs.F_OK, (err) => { - if (err) { - res.status(404).send('File not found or is invalid.'); - return; - } - - const type = getFileType(filePath); - const mimeType = mime.lookup(filePath); - - if (type === config.files.other) { - res.contentType('text/plain'); - res.sendFile(filePath); - return; - } else { - res.render('file', { filename, fileType: type, fileUrl: `${config.url}/file/raw/${filename}`, mimeType }); - return; - } - }); -}); - -app.get('/file/raw/:filename', (req, res) => { - const filename = req.params.filename; - const filePath = path.join(config.storagePath, filename); - const isValid = isPathValid(filename, filePath); - - if (!isValid) { - res.status(400).send('Invalid input.'); - return; - } - fs.access(filePath, fs.F_OK, (err) => { if (err) { res.status(404).send('File not found or is invalid.'); diff --git a/views/file.ejs b/views/file.ejs deleted file mode 100644 index be9f674..0000000 --- a/views/file.ejs +++ /dev/null @@ -1,46 +0,0 @@ - - -
- - -