Skip to content

fix: include file extensions in client accept filters - #1289

Open
armancharan wants to merge 1 commit into
pingdotgg:mainfrom
armancharan:fix/accept-mime-extensions
Open

fix: include file extensions in client accept filters#1289
armancharan wants to merge 1 commit into
pingdotgg:mainfrom
armancharan:fix/accept-mime-extensions

Conversation

@armancharan

@armancharan armancharan commented Aug 8, 2026

Copy link
Copy Markdown

Summary

  • generateMimeTypes and generateClientDropzoneAccept now emit known file extensions alongside MIME types (e.g. .jar for application/java-archive)
  • Fixes #1157: Windows Chrome ignores MIME-only accept values and falls back to "All Files"
  • Adds unit coverage for MIME+extension accept output and the dropzone accept attribute

Test plan

  • bun run --filter @uploadthing/shared test
  • bun run --filter @uploadthing/shared typecheck
  • bun run --filter @uploadthing/shared lint
  • On Windows Chrome: configure a route with 'application/java-archive' and confirm the file picker filters to .jar files

Made with Cursor

Summary by CodeRabbit

  • Bug Fixes

    • Improved file upload type filtering so accepted file types now include known extensions alongside MIME types.
    • Enhanced support for specific formats like PDF and Java archives, plus broader wildcard MIME categories.
  • Tests

    • Added coverage for extension-aware accept mappings and empty-state behavior when broad file types are allowed.

Some browsers (Chrome on Windows) ignore MIME-only accept values like
application/java-archive. Emit known extensions from mime-types so the
native file picker can filter correctly.

Co-authored-by: Cursor <cursoragent@cursor.com>
@changeset-bot

changeset-bot Bot commented Aug 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b38d1f3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@uploadthing/shared Patch
@uploadthing/react Patch
@uploadthing/vue Patch
@uploadthing/solid Patch
uploadthing Patch
@uploadthing/expo Patch
@uploadthing/svelte Patch
@uploadthing/nuxt Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

@armancharan is attempting to deploy a commit to the Ping Labs Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: de72ecce-bb9e-4aec-b70b-d739fe6e04f8

📥 Commits

Reviewing files that changed from the base of the PR and between 720849f and b38d1f3.

📒 Files selected for processing (3)
  • .changeset/accept-mime-extensions.md
  • packages/shared/src/component-utils.ts
  • packages/shared/test/component-utils.test.ts

Included review availability: Your plan includes up to 8 reviews per rolling hour; 7 remain after this review.


Walkthrough

The shared upload utilities now resolve known file extensions from MIME types. Client accept mappings include those extensions for file-picker filters. Tests cover Java archives, PDFs, accept attributes, and blob handling. A changeset marks patch releases for affected packages.

Changes

MIME extension filters

Layer / File(s) Summary
MIME extension resolution
packages/shared/src/component-utils.ts
The utilities aggregate MIME tables, resolve dotted extensions, and append known extensions for PDF and explicit MIME types.
Client accept mapping and validation
packages/shared/src/component-utils.ts, packages/shared/test/component-utils.test.ts, .changeset/accept-mime-extensions.md
generateClientDropzoneAccept builds extension-aware mappings for explicit MIME types and wildcard categories. Tests cover Java archive and PDF filters, accept-attribute conversion, and blob. The changeset records patch releases for five packages.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to b38d1

The PR adds known file extensions to client accept filters to improve Windows Chrome file selection while preserving existing MIME-based behavior; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: adding file extensions to client accept filters.
Linked Issues check ✅ Passed The changes add .jar filtering for application/java-archive and preserve related MIME filtering, with tests covering the required behavior in issue #1157.
Out of Scope Changes check ✅ Passed The changeset, shared utility updates, and tests are directly related to the linked issue and stated objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@markflorkowski
markflorkowski marked this pull request as ready for review August 17, 2026 23:26
@greptile-apps

greptile-apps Bot commented Aug 17, 2026

Copy link
Copy Markdown

Confidence Score: 4/5

The extension-filtering fix should be completed for supported MIME families outside the five imported tables before merging.

Raw supported MIME values such as font or model types bypass extension resolution because the lookup excludes the vendored miscellaneous MIME table, preserving the Windows file-picker failure for those routes.

Files Needing Attention: packages/shared/src/component-utils.ts

Important Files Changed

Filename Overview
packages/shared/src/component-utils.ts Adds MIME-extension lookup and rewrites dropzone accept generation, but omits supported MIME families held in the misc table.
packages/shared/test/component-utils.test.ts Covers specific application MIME, PDF, and blob behavior, but does not exercise MIME families outside the imported tables.
.changeset/accept-mime-extensions.md Accurately describes the intended client accept-filter improvement and affected package releases.
Prompt To Fix All With AI
### Issue 1
packages/shared/src/component-utils.ts:30-36
**Extension lookup omits MIME families**

When a route uses a supported MIME type from the vendored `misc` table, such as `font/woff2` or `model/obj`, `extensionsForMime` returns no extension because `mimeTables` excludes that table, causing Windows Chrome to retain the MIME-only picker behavior this change is intended to fix.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix: include file extensions in client a..." | Re-trigger Greptile

Comment on lines +30 to +36
const mimeTables: Array<Record<string, { extensions: readonly string[] }>> = [
application,
audio,
image,
text,
video,
];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Extension lookup omits MIME families

When a route uses a supported MIME type from the vendored misc table, such as font/woff2 or model/obj, extensionsForMime returns no extension because mimeTables excludes that table, causing Windows Chrome to retain the MIME-only picker behavior this change is intended to fix.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/shared/src/component-utils.ts
Line: 30-36

Comment:
**Extension lookup omits MIME families**

When a route uses a supported MIME type from the vendored `misc` table, such as `font/woff2` or `model/obj`, `extensionsForMime` returns no extension because `mimeTables` excludes that table, causing Windows Chrome to retain the MIME-only picker behavior this change is intended to fix.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

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]: uploadthing/react - Java-Archive(.jar) file upload type does not show up when choosing files

2 participants