fix(pdf-compress): stream large uploads via busboy instead of arrayBuffer

req.arrayBuffer() fails with 502 on files >100MB because it tries to
buffer the entire body in memory before the route handler runs.

New approach: busboy streams the multipart body directly to a temp file
on disk — never buffers the whole request in memory. Works for any size.

Shared helper: parse-upload.ts (busboy streaming, 500MB limit, fields).
Both local (qpdf) and cloud (iLovePDF) routes refactored to use it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
AI Assistant
2026-03-13 18:07:16 +02:00
parent f5deccd8ea
commit 5a7de39f6a
5 changed files with 211 additions and 210 deletions
+2
View File
@@ -12,6 +12,7 @@
"@prisma/client": "^6.19.2",
"axios": "^1.13.6",
"axios-cookiejar-support": "^6.0.5",
"busboy": "^1.6.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"docx": "^9.6.0",
@@ -36,6 +37,7 @@
},
"devDependencies": {
"@tailwindcss/postcss": "^4",
"@types/busboy": "^1.5.4",
"@types/jszip": "^3.4.0",
"@types/node": "^20",
"@types/nodemailer": "^7.0.11",