fix: add missing image MIME types (AVIF, JXL, CR3, RW2) and fix BMP#570
Merged
mmattel merged 2 commits intoowncloud:mainfrom Apr 16, 2026
Merged
fix: add missing image MIME types (AVIF, JXL, CR3, RW2) and fix BMP#570mmattel merged 2 commits intoowncloud:mainfrom
mmattel merged 2 commits intoowncloud:mainfrom
Conversation
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>
mklos-kw
approved these changes
Apr 16, 2026
Member
|
Thank you for the contribution and validating change with test |
|
As @paul43210 cannot merge, I do on his request 😄 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The hardcoded MIME type map in
pkg/mime/mime.gowas missing entries for several modern image formats. Files with these extensions were detected asapplication/octet-stream, making them invisible to KQL queries likeMediatype:image/*in the oCIS search index.Changes
.avif→image/avif(IANA registered, RFC 8843 — used by modern phones, Chrome, Firefox, Safari).jxl→image/jxl(IANA registered — JPEG XL, next-gen codec).cr3→image/x-canon-cr3(Canon's current RAW format, successor to CR2).rw2→image/x-panasonic-rw2(Panasonic RAW format).bmpfrom legacyimage/x-ms-bmpto IANA standardimage/bmp(RFC 7903)pkg/mime/mime_test.go— tests forDetect()covering all image formats, case insensitivity, andRegisterMime()How we found this
Uploaded an AVIF file (
dog-puppy-on-garden-royalty-free-image-1586966191.avif) to oCIS. A KQL search forMediatype:image/*did not return it, while a filename search did. Traced the issue tomime.Detect()which only checks the hardcodedmimeTypesmap and does not fall back to the OSmime.typesdatabase (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-streamin 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.avif,.jxl,.cr3,.rw2,.bmpfiles to oCISMediatype:image/*returns all of themMediatype:image/avifreturns only AVIF files🤖 Generated with Claude Code