2024-05-01 13:52:12 +00:00
|
|
|
const OutputFileArchiveManager = require('./OutputFileArchiveManager')
|
|
|
|
const { expressify } = require('@overleaf/promise-utils')
|
2024-06-18 08:19:08 +00:00
|
|
|
const { pipeline } = require('node:stream/promises')
|
2024-05-01 13:52:12 +00: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 08:27:13 +00:00
|
|
|
buildId
|
2024-05-01 13:52:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
res.attachment('output.zip')
|
|
|
|
res.setHeader('X-Content-Type-Options', 'nosniff')
|
2024-06-18 08:19:08 +00:00
|
|
|
await pipeline(archive, res)
|
2024-05-01 13:52:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { createOutputZip: expressify(createOutputZip) }
|