From 27cbb0a85c04a2f40ba759f95b0746c787909c5a Mon Sep 17 00:00:00 2001 From: gilesb Date: Sun, 11 Jan 2026 16:18:56 +0000 Subject: [PATCH] Store MIME type in database during upload Detect actual MIME type from file content and store it instead of generic "media" type. This enables proper media categorization and filtering in the UI. Co-Authored-By: Claude Opus 4.5 --- app/services/cache_service.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/services/cache_service.py b/app/services/cache_service.py index 2535dcd..4e62823 100644 --- a/app/services/cache_service.py +++ b/app/services/cache_service.py @@ -463,16 +463,19 @@ class CacheService: tmp.write(content) tmp_path = Path(tmp.name) + # Detect MIME type before moving file + mime_type = get_mime_type(tmp_path) + # Store in cache cached, ipfs_cid = self.cache.put(tmp_path, node_type="upload", move=True) content_hash = cached.content_hash - # Save to database + # Save to database with detected MIME type await self.db.create_cache_item(content_hash, ipfs_cid) await self.db.save_item_metadata( content_hash=content_hash, actor_id=actor_id, - item_type="media", + item_type=mime_type, # Store actual MIME type filename=filename )