Skip to content

[FIX] Save and serve files with correct Content-Type#4404

Open
kwerie wants to merge 9 commits intovendurehq:masterfrom
kwerie:fix/pdf-content-type
Open

[FIX] Save and serve files with correct Content-Type#4404
kwerie wants to merge 9 commits intovendurehq:masterfrom
kwerie:fix/pdf-content-type

Conversation

@kwerie
Copy link
Copy Markdown
Contributor

@kwerie kwerie commented Feb 24, 2026

Description

PDFs were served with application/octet-stream, causing Chromium-based browsers to download them instead of opening them in a new tab. Add application/pdf to the MIME type mapping so PDFs are served with the correct Content-Type header.

Also when saving files to an S3 bucket, the content type wasn't being set.

Breaking changes

No

Screenshots

N/A

Checklist

📌 Always:

  • I have set a clear title
  • My PR is small and contains a single feature
  • I have checked my own PR

👍 Most of the time:

  • I have added or updated test cases
  • I have updated the README if needed

Fixes #4403

PDFs were served with application/octet-stream, causing Chromium-based
browsers to download them instead of opening them in a new tab. Add
application/pdf to the MIME type mapping so PDFs are served with the
correct Content-Type header.
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vendure-storybook Ready Ready Preview, Comment Mar 25, 2026 9:18am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6f542874-9a66-435d-9b22-494f4aabfa7f

📥 Commits

Reviewing files that changed from the base of the PR and between 4f8cc9d and 388f85e.

📒 Files selected for processing (1)
  • packages/asset-server-plugin/src/asset-server.ts

📝 Walkthrough

Walkthrough

Adds PDF MIME-type handling to the asset-server-plugin: getMimeType now returns application/pdf for .pdf files. The plugin dependency list includes mime-types, and S3 uploads set ContentType using mime.lookup(fileName) || 'application/octet-stream'. The end-to-end tests were extended to upload test.pdf and assert the MIME type is application/pdf.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: fixing Content-Type headers for file serving, particularly for PDFs.
Description check ✅ Passed The description covers the main problem, solution, breaking changes status, and relevant checklist items per the template requirements.
Linked Issues check ✅ Passed The PR implementation fully addresses both requirements from #4403: PDF MIME type mapping added and S3 content type handling implemented with tests.
Out of Scope Changes check ✅ Passed All changes directly support the stated objectives of fixing PDF Content-Type handling and S3 uploads; no out-of-scope modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kwerie kwerie changed the base branch from minor to master February 24, 2026 09:12
@kwerie kwerie changed the title [FIX] Serve PDFs with correct Content-Type [FIX] Save and serve files with correct Content-Type Mar 3, 2026
Copy link
Copy Markdown
Collaborator

@biggamesmallworld biggamesmallworld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great fix! The S3 ContentType addition is a valuable improvement beyond just the serving-side fix. Thanks for the contribution.

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.

Content-Type not set correctly for .pdf assets (and assets uploaded to S3)

2 participants