Download mission file

This commit is contained in:
Björn Dahlgren 2014-04-05 19:27:54 +00:00
parent 76c05d9c7d
commit 11150bc59b
2 changed files with 8 additions and 3 deletions

View File

@ -1,5 +1,5 @@
<td> <td>
<a href='#missions/<%-name%>'><%-name%></a> <a href='/api/missions/<%-name%>'><%-name%></a>
</td> </td>
<td> <td>
<button type="button" class="btn btn-danger btn-xs delete"> <button type="button" class="btn btn-danger btn-xs delete">

View File

@ -21,7 +21,6 @@ exports.create = function(req, res){
fs.readFile(missionFile.path, function (err, data) { fs.readFile(missionFile.path, function (err, data) {
var newPath = config.path + '/mpmissions/' + missionFile.name; var newPath = config.path + '/mpmissions/' + missionFile.name;
console.log(newPath);
fs.writeFile(newPath, data, function (err) { fs.writeFile(newPath, data, function (err) {
res.json(missionFile); res.json(missionFile);
}); });
@ -29,7 +28,13 @@ exports.create = function(req, res){
}; };
exports.show = function(req, res){ exports.show = function(req, res){
res.send('download mission ' + req.params.mission); var path = config.path + '/mpmissions/' + req.params.mission;
if (req.params.format) {
path += '.' + req.params.format;
}
res.download(path);
}; };
exports.destroy = function(req, res){ exports.destroy = function(req, res){