Add route to download app backups

This commit is contained in:
Johannes Zellner
2022-11-03 22:13:57 +01:00
parent ad3e593f01
commit c4c90cfaf9
3 changed files with 35 additions and 0 deletions

View File

@@ -56,6 +56,7 @@ exports = module.exports = {
downloadFile,
updateBackup,
downloadBackup,
getLimits,
getGraphs,
@@ -852,6 +853,17 @@ async function updateBackup(req, res, next) {
next(new HttpSuccess(200, {}));
}
async function downloadBackup(req, res, next) {
assert.strictEqual(typeof req.app, 'object');
assert.strictEqual(typeof req.params.backupId, 'string');
const [error, result] = await safe(apps.getBackupDownloadStream(req.app, req.params.backupId));
if (error) return next(BoxError.toHttpError(error));
res.attachment(`${req.params.backupId}.tgz`);
result.pipe(res);
}
async function uploadFile(req, res, next) {
assert.strictEqual(typeof req.app, 'object');