2024-05-01 09:52:12 -04:00
|
|
|
const OutputFileArchiveManager = require('./OutputFileArchiveManager')
|
|
|
|
const { expressify } = require('@overleaf/promise-utils')
|
2024-06-18 04:19:08 -04:00
|
|
|
const { pipeline } = require('node:stream/promises')
|
2024-05-01 09:52:12 -04:00
|
|
|
|
|
|
|
async function createOutputZip(req, res) {
|
|
|
|
const {
|
|
|
|
project_id: projectId,
|
|
|
|
user_id: userId,
|
|
|
|
build_id: buildId,
|
|
|
|
} = req.params
|
|
|
|
|
|
|
|
const archive = await OutputFileArchiveManager.archiveFilesForBuild(
|
|
|
|
projectId,
|
|
|
|
userId,
|
2024-06-12 04:27:13 -04:00
|
|
|
buildId
|
2024-05-01 09:52:12 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
res.attachment('output.zip')
|
|
|
|
res.setHeader('X-Content-Type-Options', 'nosniff')
|
2024-06-18 04:19:08 -04:00
|
|
|
await pipeline(archive, res)
|
2024-05-01 09:52:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { createOutputZip: expressify(createOutputZip) }
|