Permalink
Browse files

add LICENSE & add upload path to config

  • Loading branch information...
tdjsnelling committed Jan 30, 2018
1 parent 427df4c commit 983559180fa75ced56aba1598e425d4f2ff90366
Showing with 29 additions and 7 deletions.
  1. +21 −0 LICENSE
  2. +1 −0 config.json
  3. +7 −7 index.js
View
21 LICENSE
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Tom Snelling
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
View
@@ -1,6 +1,7 @@
{
"port": 8000,
"rootUrl": "https://0x1.host/",
"uploadPath": "uploads",
"maxFileSize": 268435456,
"doNotAllow": [
"application/x-dosexec",
View
@@ -11,16 +11,16 @@ var consolidate = require('consolidate');
var config = require('./config');
var port = config.port;
var rootUrl = config.rootUrl;
var uploadPath = config.uploadPath;
var maxFileSize = config.maxFileSize;
var doNotAllow = config.doNotAllow;
var filePersistence = config.filePersistence;
var abuseEmail = config.abuseEmail;
var storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, 'uploads')
cb(null, uploadPath)
},
filename: function (req, file, cb) {
var mimeType = mime.lookup(file.originalname);
@@ -36,13 +36,13 @@ function fileFilter(req, file, cb) {
cb(null, false);
}
else {
cb(null, true);
}
cb(null, true);
}
}
var upload = multer({ limits: { fileSize: maxFileSize }, storage: storage, fileFilter: fileFilter });
app.use(express.urlencoded());
app.use(express.urlencoded({ extended: true }));
app.set('views', __dirname + '/public');
app.set('view engine', 'ejs');
app.engine('html', consolidate.swig);
@@ -61,9 +61,9 @@ app.post('/', upload.single('file'), (req, res) => {
});
app.get('/:fileId', (req, res) => {
var fileToSend = path.join(__dirname, '/uploads', req.params.fileId);
var fileToSend = path.join(__dirname, uploadPath, req.params.fileId);
if (fs.existsSync(fileToSend)) {
res.sendFile(fileToSend);
res.sendFile(fileToSend);
}
else {
res.sendStatus(404);

0 comments on commit 9835591

Please sign in to comment.