Add backup download route if backend supports it

This commit is contained in:
Johannes Zellner
2016-09-16 18:14:36 +02:00
parent c9c1964e09
commit 6352064e6c
7 changed files with 74 additions and 2 deletions
+12 -1
View File
@@ -3,7 +3,8 @@
exports = module.exports = {
get: get,
create: create,
createDownloadUrl: createDownloadUrl
createDownloadUrl: createDownloadUrl,
download: download
};
var assert = require('assert'),
@@ -52,3 +53,13 @@ function createDownloadUrl(req, res, next) {
next(new HttpSuccess(200, result));
});
}
function download(req, res, next) {
assert.strictEqual(typeof req.params.backupId, 'string');
backups.getLocalDownloadPath(req.params.backupId, function (error, result) {
if (error) return next(new HttpError(500, error));
res.sendFile(result);
});
}