diff --git a/api/ovdashboard_api/routers/v1/__init__.py b/api/ovdashboard_api/routers/v1/__init__.py index 38f8300..0a032a9 100644 --- a/api/ovdashboard_api/routers/v1/__init__.py +++ b/api/ovdashboard_api/routers/v1/__init__.py @@ -7,7 +7,7 @@ This file: Main API router definition. from fastapi import APIRouter # from . import aggregate, calendar, file, image, misc, text, ticker -from . import file, misc +from . import file, image, misc router = APIRouter(prefix="/api/v1") @@ -15,7 +15,7 @@ router.include_router(misc.router) # router.include_router(text.router) # router.include_router(ticker.router) -# router.include_router(image.router) +router.include_router(image.router) router.include_router(file.router) # router.include_router(calendar.router) diff --git a/api/ovdashboard_api/routers/v1/image.py b/api/ovdashboard_api/routers/v1/image.py index d613829..cea6a72 100644 --- a/api/ovdashboard_api/routers/v1/image.py +++ b/api/ovdashboard_api/routers/v1/image.py @@ -15,9 +15,9 @@ from fastapi import APIRouter, Depends from fastapi.responses import StreamingResponse from PIL import Image -from ...config import Config, ImageUIConfig -from ...dav_common import webdav_ensure_files, webdav_ensure_path -from ...dav_file import DavFile +from ...core.config import Config, ImageUIConfig, get_config +from ...core.dav_common import webdav_ensure_files, webdav_ensure_path +from ...core.webdav import WebDAV from ._common import FileNameLister, PrefixFinder, PrefixUnique _logger = getLogger(__name__) @@ -80,10 +80,10 @@ async def get_image( prefix: str, name: str = Depends(image_unique), ) -> StreamingResponse: - cfg = await Config.get() - - dav_file = DavFile(f"{await image_lister.remote_path}/{name}") - img = Image.open(BytesIO(await dav_file.as_bytes)).convert(cfg.image.mode) + cfg = await get_config() + img = Image.open( + BytesIO(await WebDAV.read_bytes(f"{await image_lister.remote_path}/{name}")) + ) img_buffer = BytesIO() img.save(img_buffer, **cfg.image.save_params) @@ -101,6 +101,6 @@ async def get_image( response_model=ImageUIConfig, ) async def get_ui_config( - cfg: Config = Depends(Config.get), + cfg: Config = Depends(get_config), ) -> ImageUIConfig: return cfg.image