Created
April 18, 2023 16:32
-
-
Save TimMikeladze/b93055dae1f8626b3b21c61490648238 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```ts | |
import AdmZip from 'adm-zip'; | |
import { NextApiRequest, NextApiResponse } from 'next'; | |
export default async function handler( | |
req: NextApiRequest, | |
res: NextApiResponse, | |
) { | |
const zip = new AdmZip(); | |
zip.addFile( | |
`db.sql`, | |
Buffer.from(`${yourSQLData}`, `utf8`), | |
``, | |
); | |
res.setHeader(`Content-Type`, `application/zip`); | |
res.setHeader(`Content-Disposition`, `attachment; filename=export.zip`); | |
res.send(zip.toBuffer()); | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment