overleaf/services/clsi/app/js/OutputController.js
andrew rumble 487d9125a2 Improve stream error safety
GitOrigin-RevId: de4c512a62d304b3eeb2a1521aac173fa93d8411
2024-09-24 08:05:15 +00:00

23 lines
624 B
JavaScript

const OutputFileArchiveManager = require('./OutputFileArchiveManager')
const { expressify } = require('@overleaf/promise-utils')
const { pipeline } = require('node:stream/promises')
async function createOutputZip(req, res) {
const {
project_id: projectId,
user_id: userId,
build_id: buildId,
} = req.params
const archive = await OutputFileArchiveManager.archiveFilesForBuild(
projectId,
userId,
buildId
)
res.attachment('output.zip')
res.setHeader('X-Content-Type-Options', 'nosniff')
await pipeline(archive, res)
}
module.exports = { createOutputZip: expressify(createOutputZip) }