Fix the url for download

This commit is contained in:
Raymond Feng 2013-06-27 08:51:46 -07:00
parent 210618d7b3
commit 687c086808
1 changed files with 6 additions and 4 deletions

View File

@ -38,20 +38,22 @@ app.post('/upload/:container', function (req, res, next) {
app.get('/download', function (req, res, next) { app.get('/download', function (req, res, next) {
handler.client.getContainers(function (err, containers) { handler.client.getContainers(function (err, containers) {
var html = "<body><h1>Containers</h1><ul>"; var html = "<html><body><h1>Containers</h1><ul>";
containers.forEach(function (f) { containers.forEach(function (f) {
html += "<li><a href='" + f.name + "'>" + f.name + "</a></li>" html += "<li><a href='/download/" + f.name + "'>" + f.name + "</a></li>"
}); });
html += "</body></html>";
res.send(200, html); res.send(200, html);
}); });
}); });
app.get('/download/:container', function (req, res, next) { app.get('/download/:container', function (req, res, next) {
handler.client.getFiles(req.params.container, function (err, files) { handler.client.getFiles(req.params.container, function (err, files) {
var html = "<body><h1>Files</h1><ul>"; var html = "<html><body><h1>Files</h1><ul>";
files.forEach(function (f) { files.forEach(function (f) {
html += "<li><a href='" + f.container + "/" + f.name + "'>" + f.container + "/" + f.name + "</a></li>" html += "<li><a href='/download/" + f.container + "/" + f.name + "'>" + f.container + "/" + f.name + "</a></li>"
}); });
html += "</body></html>";
res.send(200, html); res.send(200, html);
}); });
}); });