mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
multi missions file upload
This commit is contained in:
parent
55a8985701
commit
c38f23f54c
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h3 class="panel-title">Download Mission</h3>
|
<h3 class="panel-title">Download Missions</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body" id="workshop"></div>
|
<div class="panel-body" id="workshop"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
<form class="form" role="form" enctype="multipart/form-data">
|
<form class="form" role="form" enctype="multipart/form-data">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="mission" class="control-label">Mission File</label>
|
<label for="missions" class="control-label">Mission Files</label>
|
||||||
<input type="file" class="form-control path" name="mission" id="mission" data-field="mission">
|
<input multiple="multiple"
|
||||||
|
accept=".pbo"
|
||||||
|
type="file"
|
||||||
|
class="form-control path"
|
||||||
|
name="missions"
|
||||||
|
id="missions"
|
||||||
|
data-field="missions"
|
||||||
|
>
|
||||||
<span class="help-block">Only supports missions packed as a PBO</span>
|
<span class="help-block">Only supports missions packed as a PBO</span>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary ladda-button" data-style="expand-left">
|
<button type="submit" class="btn btn-primary ladda-button" data-style="expand-left">
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
var express = require('express')
|
var express = require('express')
|
||||||
var multer = require('multer')
|
var multer = require('multer')
|
||||||
var upload = multer({ storage: multer.diskStorage({}) })
|
var upload = multer({ storage: multer.diskStorage({}) })
|
||||||
|
var async = require('async')
|
||||||
|
|
||||||
module.exports = function (missionsManager) {
|
module.exports = function (missionsManager) {
|
||||||
var router = express.Router()
|
var router = express.Router()
|
||||||
@ -15,20 +16,22 @@ module.exports = function (missionsManager) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
router.post('/', upload.single('mission'), function (req, res) {
|
router.post('/', upload.array('missions', 64), function (req, res) {
|
||||||
var missionFile = req.file
|
async.parallelLimit(
|
||||||
|
req.files.map(function (missionFile) {
|
||||||
if (!missionFile) {
|
return function (next) {
|
||||||
return res.status(400).send('No mission file uploaded')
|
missionsManager.handleUpload(missionFile, next)
|
||||||
}
|
}
|
||||||
|
}),
|
||||||
missionsManager.handleUpload(missionFile, function (err) {
|
8,
|
||||||
if (err) {
|
function (err) {
|
||||||
res.status(500).send(err)
|
if (err) {
|
||||||
} else {
|
res.status(500).send(err)
|
||||||
res.status(200).json({success: true})
|
} else {
|
||||||
|
res.status(200).json({success: true})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
router.get('/:mission', function (req, res) {
|
router.get('/:mission', function (req, res) {
|
||||||
|
Loading…
Reference in New Issue
Block a user