Skip to content

Fix .mov file uploads: handle missing MIME type in browsers like Firefox#601

Open
Jefsky wants to merge 1 commit into
abi:mainfrom
Jefsky:fix/mov-file-mime-type-handling
Open

Fix .mov file uploads: handle missing MIME type in browsers like Firefox#601
Jefsky wants to merge 1 commit into
abi:mainfrom
Jefsky:fix/mov-file-mime-type-handling

Conversation

@Jefsky

@Jefsky Jefsky commented May 30, 2026

Copy link
Copy Markdown

Problem

When uploading a .mov video file, the browser (particularly Firefox) sometimes reports an empty MIME type (file.type === ""). This causes FileReader.readAsDataURL() to produce a data URL with data:application/octet-stream;base64,... instead of the correct data:video/quicktime;base64,....

The existing fileToDataURL() function had a fallback that only ran when file.type was non-empty, so the MIME type was never corrected for these browsers. The incorrect application/octet-stream prefix then caused files to be misclassified downstream.

Root Cause

The condition result.startsWith("data:application/octet-stream") && file.type skipped the MIME correction when file.type was an empty string (a falsy value in JavaScript).

Fix

Added an inferMimeType() helper that:

  1. Uses file.type when available (same as before)
  2. Falls back to mapping the file extension to a known MIME type when file.type is empty

The extension-to-MIME mapping covers .mov, .mp4, .webm, .png, .jpg/.jpeg, .gif, and .webp.

The fix is applied to both file upload components:

  • frontend/src/components/ImageUpload.tsx
  • frontend/src/components/unified-input/tabs/UploadTab.tsx

Fixes #384

When uploading .mov files in Firefox, the browser reports an empty MIME
type, causing FileReader.readAsDataURL to return a data URL with
'application/octet-stream'. The existing fallback in fileToDataURL only
corrected the MIME type when file.type was non-empty, so .mov files
ended up with the wrong MIME type prefix.

This change introduces inferMimeType() which falls back to mapping the
file extension when file.type is empty. The same fix is applied to both
ImageUpload.tsx and UploadTab.tsx.

Fixes abi#384
@Jefsky

Jefsky commented Jun 9, 2026

Copy link
Copy Markdown
Author

Friendly bump — this PR has been sitting for a bit. The fix detects .mov uploads with no MIME type (Firefox case) and treats them as video/quicktime so the upload flow accepts them (~68 lines, 2 files, both in the unified-input upload path). Happy to address any feedback or split the change if needed.

@abi

abi commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Will take a look soon

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.

Support .mov for video upload

3 participants