Add route to download app backups
This commit is contained in:
@@ -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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user