mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Mission Upload broken after Express 4 update
This commit is contained in:
parent
59364c299b
commit
e58cc6ac0a
@ -47,7 +47,7 @@ Missions.prototype.list = function (cb){
|
||||
};
|
||||
|
||||
Missions.prototype.handleUpload = function (uploadedFile, cb) {
|
||||
var filename = decodeURI(uploadedFile.name.toLowerCase());
|
||||
var filename = decodeURI(uploadedFile.originalname.toLowerCase());
|
||||
fs.rename(uploadedFile.path, path.join(this.missionsPath(), filename), function (err) {
|
||||
cb(err);
|
||||
});
|
||||
|
@ -21,6 +21,7 @@
|
||||
"gamedig": "0.2.25",
|
||||
"lodash": "^3.6.0",
|
||||
"morgan": "^1.8.1",
|
||||
"multer": "^1.3.0",
|
||||
"playwithsix": "0.0.11",
|
||||
"serve-static": "^1.12.1",
|
||||
"slugify": "^1.1.0",
|
||||
|
@ -1,4 +1,6 @@
|
||||
var express = require('express');
|
||||
var multer = require('multer');
|
||||
var upload = multer({ storage: multer.diskStorage({}) });
|
||||
|
||||
module.exports = function (missionsManager) {
|
||||
var router = express.Router();
|
||||
@ -13,13 +15,18 @@ module.exports = function (missionsManager) {
|
||||
});
|
||||
});
|
||||
|
||||
router.post('/', function (req, res) {
|
||||
var missionFile = req.files.mission;
|
||||
router.post('/', upload.single('mission'), function (req, res) {
|
||||
var missionFile = req.file;
|
||||
|
||||
if (!missionFile) {
|
||||
return res.status(400).send('No mission file uploaded');;
|
||||
}
|
||||
|
||||
missionsManager.handleUpload(missionFile, function (err) {
|
||||
if (err) {
|
||||
res.status(500).send(err);
|
||||
} else {
|
||||
res.status(204);
|
||||
res.status(200).json({success: true});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user