feat: Separate asset origin type from content type for improved asset categorization and handling.
This commit is contained in:
@@ -9,7 +9,7 @@ from starlette.requests import Request
|
||||
from starlette.responses import Response, JSONResponse
|
||||
|
||||
from api.models.AssetDTO import AssetsResponse, AssetResponse
|
||||
from models.Asset import Asset, AssetType
|
||||
from models.Asset import Asset, AssetType, AssetContentType
|
||||
from repos.dao import DAO
|
||||
from api.dependency import get_dao
|
||||
import asyncio
|
||||
@@ -105,7 +105,8 @@ async def upload_asset(
|
||||
|
||||
asset = Asset(
|
||||
name=file.filename or "upload",
|
||||
type=AssetType.IMAGE,
|
||||
type=AssetType.UPLOADED,
|
||||
content_type=AssetContentType.IMAGE,
|
||||
linked_char_id=linked_char_id,
|
||||
data=data,
|
||||
thumbnail=thumbnail_bytes
|
||||
@@ -119,6 +120,7 @@ async def upload_asset(
|
||||
id=asset.id,
|
||||
name=asset.name,
|
||||
type=asset.type.value if hasattr(asset.type, "value") else asset.type,
|
||||
content_type=asset.content_type.value if hasattr(asset.content_type, "value") else asset.content_type,
|
||||
linked_char_id=asset.linked_char_id,
|
||||
created_at=asset.created_at,
|
||||
url=asset.url
|
||||
@@ -145,7 +147,7 @@ async def regenerate_thumbnails(dao: DAO = Depends(get_dao)):
|
||||
updated = 0
|
||||
|
||||
for asset in assets:
|
||||
if asset.type == AssetType.IMAGE and asset.data :
|
||||
if asset.content_type == AssetContentType.IMAGE and asset.data :
|
||||
try:
|
||||
thumb = await asyncio.to_thread(create_thumbnail, asset.data)
|
||||
if thumb:
|
||||
|
||||
Reference in New Issue
Block a user