diff --git a/packages/builder/src/components/start/ExportAppModal.svelte b/packages/builder/src/components/start/ExportAppModal.svelte index 4b2742b609..c6f3fceea7 100644 --- a/packages/builder/src/components/start/ExportAppModal.svelte +++ b/packages/builder/src/components/start/ExportAppModal.svelte @@ -16,9 +16,8 @@ const exportApp = async () => { const id = published ? app.prodId : app.devId - const appName = encodeURIComponent(app.name) - const url = `/api/backups/export?appId=${id}&appname=${appName}&excludeRows=${excludeRows}` - await downloadFile(url) + const url = `/api/backups/export?appId=${id}` + await downloadFile(url, { excludeRows }) } export async function downloadFile(url, body) { diff --git a/packages/server/src/api/controllers/backup.ts b/packages/server/src/api/controllers/backup.ts index 53e1bd1792..60312bd36c 100644 --- a/packages/server/src/api/controllers/backup.ts +++ b/packages/server/src/api/controllers/backup.ts @@ -1,14 +1,22 @@ import sdk from "../../sdk" -import { events, context } from "@budibase/backend-core" +import { events, context, db } from "@budibase/backend-core" import { DocumentType } from "../../db/utils" -import { isQsTrue } from "../../utilities" +import { Ctx } from "@budibase/types" + +interface ExportAppDumpRequest { + excludeRows: boolean +} + +export async function exportAppDump(ctx: Ctx) { + const { appId } = ctx.query as any + const { excludeRows } = ctx.request.body + + const [app] = await db.getAppsByIDs([appId]) + const appName = app.name -export async function exportAppDump(ctx: any) { - let { appId, excludeRows } = ctx.query // remove the 120 second limit for the request ctx.req.setTimeout(0) - const appName = decodeURI(ctx.query.appname) - excludeRows = isQsTrue(excludeRows) + const backupIdentifier = `${appName}-export-${new Date().getTime()}.tar.gz` ctx.attachment(backupIdentifier) ctx.body = await sdk.backups.streamExportApp(appId, excludeRows)