Files

24 lines
719 B
JavaScript
Raw Permalink Normal View History

2021-02-04 18:44:16 +08:00
import Router from 'koa-router'
import fs from 'fs'
import exportsService from '../service/exports-service.js'
2021-02-05 14:45:53 +08:00
2021-02-04 18:44:16 +08:00
const router = Router()
2021-02-08 21:16:56 +08:00
router.prefix('/api/exports')
2021-02-04 18:44:16 +08:00
router.post('/toZip', async function (ctx, next) {
// const request = ctx.request
// const query = request.query
const body = ctx.request.body
// const req_queryString = request.queryString
2021-02-05 18:13:24 +08:00
const { zipPath, fileName } = await exportsService.exportsToZip(body.options, 'certd-run')
2021-02-04 18:44:16 +08:00
console.log('zipFile', zipPath)
ctx.set('Content-disposition', 'attachment;filename=' + fileName)
ctx.set('Content-Type', 'application/zip')
ctx.body = fs.createReadStream(zipPath)
//
// // ctx.body = Ret.success(zipPath)
})
export default router