|
@@ -18,6 +18,7 @@ module.exports = function(crowi, app) {
|
|
|
aclService,
|
|
aclService,
|
|
|
slackNotificationService,
|
|
slackNotificationService,
|
|
|
customizeService,
|
|
customizeService,
|
|
|
|
|
+ exportService,
|
|
|
} = crowi;
|
|
} = crowi;
|
|
|
|
|
|
|
|
const recommendedWhitelist = require('@commons/service/xss/recommended-whitelist');
|
|
const recommendedWhitelist = require('@commons/service/xss/recommended-whitelist');
|
|
@@ -874,6 +875,21 @@ module.exports = function(crowi, app) {
|
|
|
return res.render('admin/export');
|
|
return res.render('admin/export');
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ actions.export.download = (req, res) => {
|
|
|
|
|
+ // TODO: add express validator
|
|
|
|
|
+ const { fileName } = req.params;
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ const zipFile = exportService.getFile(fileName);
|
|
|
|
|
+ return res.download(zipFile);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (err) {
|
|
|
|
|
+ // TODO: use ApiV3Error
|
|
|
|
|
+ logger.error(err);
|
|
|
|
|
+ return res.json(ApiResponse.error());
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
actions.api = {};
|
|
actions.api = {};
|
|
|
actions.api.appSetting = async function(req, res) {
|
|
actions.api.appSetting = async function(req, res) {
|
|
|
const form = req.form.settingForm;
|
|
const form = req.form.settingForm;
|