mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
feat: download data exports directly from the server without a JS download step
This commit is contained in:
parent
fc4f106afb
commit
9c1568b911
7 changed files with 320 additions and 42 deletions
|
@ -7,6 +7,7 @@ import { z } from "zod";
|
|||
import { Case } from "../../data/entities/Case";
|
||||
import { rateLimit } from "../rateLimits";
|
||||
import { MINUTES } from "../../utils";
|
||||
import moment from "moment-timezone";
|
||||
|
||||
const caseHandlingModeSchema = z.union([
|
||||
z.literal("replace"),
|
||||
|
@ -167,7 +168,13 @@ export function initGuildsImportExportAPI(guildRouter: express.Router) {
|
|||
}
|
||||
} while (cases.length === exportBatchSize);
|
||||
|
||||
res.json(data);
|
||||
const filename = `export_${req.params.guildId}_${moment().format("YYYY-MM-DD_HH-mm-ss")}.json`;
|
||||
const serialized = JSON.stringify(data, null, 2);
|
||||
|
||||
res.setHeader("Content-Disposition", `attachment; filename=${filename}`);
|
||||
res.setHeader("Content-Type", "application/octet-stream");
|
||||
res.setHeader("Content-Length", serialized.length);
|
||||
res.send(serialized);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue