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 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-01-11 16:18:56 +00:00
parent 9c148f535d
commit 27cbb0a85c

View File

@@ -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
)