Fix the board download feature

This commit is contained in:
Ophir LOJKINE 2015-07-20 14:19:07 +02:00
parent 43370fac3d
commit dbc498acea
2 changed files with 9 additions and 5 deletions

View file

@ -3,7 +3,7 @@
"collaborative", "collaborative",
"whiteboard" "whiteboard"
], ],
"version": "1.0.0-18", "version": "1.0.0-19",
"dependencies": { "dependencies": {
"node-static": "0.7.x", "node-static": "0.7.x",
"socket.io": "0.9.x" "socket.io": "0.9.x"

View file

@ -61,14 +61,18 @@ function handler (request, response) {
} }
} else if (parts[0] === "download") { } else if (parts[0] === "download") {
var history_file = "../server-data/board-" + encodeURIComponent(parts[1]), var boardName = encodeURIComponent(parts[1]),
headers = {"Content-Type": "text/x-wbo"}; history_file = "../server-data/board-" + boardName + ".json",
headers = {
"Content-Type": "application/json",
"Content-Disposition": 'attachment; filename="'+boardName+'.wbo"'
};
var promise = fileserver.serveFile(history_file, 200, headers, request, response); var promise = fileserver.serveFile(history_file, 200, headers, request, response);
promise.on("error", function(){ promise.on("error", function(err){
console.error("Error while downloading history", err);
response.statusCode = 404; response.statusCode = 404;
response.end("ERROR: Unable to serve history file\n"); response.end("ERROR: Unable to serve history file\n");
}); });
} else { } else {
fileserver.serve(request, response, function (err, res){ fileserver.serve(request, response, function (err, res){
if (err) serveError(request, response, err); if (err) serveError(request, response, err);