mirror of
https://github.com/lovasoa/whitebophir
synced 2024-11-15 00:37:07 +00:00
Fix the board download feature
This commit is contained in:
parent
43370fac3d
commit
dbc498acea
2 changed files with 9 additions and 5 deletions
|
@ -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"
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue