Skip to content

Compress PDF export delivery by returning ZIP payload#61

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/optimize-pdf-download-speed
Draft

Compress PDF export delivery by returning ZIP payload#61
Copilot wants to merge 3 commits into
mainfrom
copilot/optimize-pdf-download-speed

Conversation

Copilot AI commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

PDF exports were noticeably slower than image ZIP downloads under constrained network conditions because the response transferred a larger raw PDF payload. This change shifts PDF delivery to a compressed ZIP package while preserving generated PDF content.

  • Backend response contract (PDF path)

    • Updated pdf_save=true result handling to return application/zip instead of raw application/pdf.
    • Response header now serves images.zip as attachment; archive contains images.pdf.
  • PDF packaging utility

    • Added build_pdf_zip_bytes in backend/pdf.py to package PDF bytes into a ZIP in-memory stream (deflate compression).
  • Targeted regression coverage

    • Added focused test to verify ZIP signature, expected entry name (images.pdf), and exact PDF byte integrity.
    • Added shared test import setup in backend test conftest.py.
with open(temp_pdf_file_path, "rb") as f:
    pdf_data = f.read()
zip_data = build_pdf_zip_bytes(pdf_data)
return Response(
    content=zip_data,
    media_type="application/zip",
    headers={"Content-Disposition": "attachment; filename=images.zip"},
)

Copilot AI changed the title [WIP] Optimize PDF download speed by compressing before transmission Compress PDF export delivery by returning ZIP payload Jun 7, 2026
Copilot AI requested a review from 14790897 June 7, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 下载PDF速度较慢,或许可以优化成打包为zip再下载

2 participants