Skip to content

fix: add missing image MIME types (AVIF, JXL, CR3, RW2) and fix BMP#570

Merged
mmattel merged 2 commits intoowncloud:mainfrom
paul43210:fix/add-avif-jxl-mimetypes
Apr 16, 2026
Merged

fix: add missing image MIME types (AVIF, JXL, CR3, RW2) and fix BMP#570
mmattel merged 2 commits intoowncloud:mainfrom
paul43210:fix/add-avif-jxl-mimetypes

Conversation

@paul43210
Copy link
Copy Markdown

Summary

The hardcoded MIME type map in pkg/mime/mime.go was missing entries for several modern image formats. Files with these extensions were detected as application/octet-stream, making them invisible to KQL queries like Mediatype:image/* in the oCIS search index.

Changes

  • Added .avifimage/avif (IANA registered, RFC 8843 — used by modern phones, Chrome, Firefox, Safari)
  • Added .jxlimage/jxl (IANA registered — JPEG XL, next-gen codec)
  • Added .cr3image/x-canon-cr3 (Canon's current RAW format, successor to CR2)
  • Added .rw2image/x-panasonic-rw2 (Panasonic RAW format)
  • Fixed .bmp from legacy image/x-ms-bmp to IANA standard image/bmp (RFC 7903)
  • Added pkg/mime/mime_test.go — tests for Detect() covering all image formats, case insensitivity, and RegisterMime()

How we found this

Uploaded an AVIF file (dog-puppy-on-garden-royalty-free-image-1586966191.avif) to oCIS. A KQL search for Mediatype:image/* did not return it, while a filename search did. Traced the issue to mime.Detect() which only checks the hardcoded mimeTypes map and does not fall back to the OS mime.types database (where AVIF is registered).

Impact

Without this fix, any oCIS feature or third-party app that queries Mediatype:image/* (search index, photo galleries, media type filters) will silently exclude AVIF, JPEG XL, CR3, and RW2 files. AVIF adoption is accelerating — iOS 16+, Android, and all major browsers support it natively.

Note on existing files

Files uploaded before this fix will retain application/octet-stream in their stored metadata. A reindex (ocis search index) will pick up the correct MIME type for the search index, but the storage provider metadata will need a re-stat or re-upload to update.

Test plan

  • go test ./pkg/mime/ -v — all 30 tests pass
  • Upload .avif, .jxl, .cr3, .rw2, .bmp files to oCIS
  • Verify Mediatype:image/* returns all of them
  • Verify Mediatype:image/avif returns only AVIF files

🤖 Generated with Claude Code

paul43210 and others added 2 commits April 8, 2026 23:04
The hardcoded MIME type map did not include entries for .avif (image/avif),
.jxl (image/jxl), .cr3 (image/x-canon-cr3), or .rw2 (image/x-panasonic-rw2).
Files with these extensions were detected as application/octet-stream, making
them invisible to KQL queries like Mediatype:image/*.

Also updated .bmp from the legacy image/x-ms-bmp to the IANA standard
image/bmp (RFC 7903).

Discovered by uploading an AVIF file to oCIS and observing that a KQL search
for Mediatype:image/* did not return it, while a filename search did. Root
cause: mime.Detect() only checks the hardcoded map and does not fall back to
the OS mime.types database where AVIF is registered.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Paul Faure <paul@faure.ca>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Paul Faure <paul@faure.ca>
@mmattel mmattel requested a review from mklos-kw April 16, 2026 07:09
@mklos-kw
Copy link
Copy Markdown
Member

Thank you for the contribution and validating change with test

@mmattel
Copy link
Copy Markdown

mmattel commented Apr 16, 2026

As @paul43210 cannot merge, I do on his request 😄

@mmattel mmattel merged commit 4b310ff into owncloud:main Apr 16, 2026
13 checks passed
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.

3 participants