add endpoint to list all profile pictures
This commit is contained in:
parent
7e84cf8ec7
commit
c467cc649a
1 changed files with 23 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ import hashlib
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, UploadFile
|
from fastapi import APIRouter, Depends, HTTPException, UploadFile
|
||||||
from fastapi.responses import StreamingResponse
|
from fastapi.responses import StreamingResponse
|
||||||
|
|
@ -99,6 +100,28 @@ async def download_image(file_name: str, flow_id: UUID, storage_service: Storage
|
||||||
raise HTTPException(status_code=500, detail=str(e))
|
raise HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/profile_pictures/list")
|
||||||
|
async def list_profile_pictures(storage_service: StorageService = Depends(get_storage_service)):
|
||||||
|
try:
|
||||||
|
config_dir = get_storage_service().settings_service.settings.config_dir
|
||||||
|
config_path = Path(config_dir)
|
||||||
|
|
||||||
|
people_path = config_path / "profile_pictures/People"
|
||||||
|
space_path = config_path / "profile_pictures/Space"
|
||||||
|
|
||||||
|
people = await storage_service.list_files(flow_id=people_path)
|
||||||
|
space = await storage_service.list_files(flow_id=space_path)
|
||||||
|
|
||||||
|
files = [Path("People") / i for i in people]
|
||||||
|
files += [Path("Space") / i for i in space]
|
||||||
|
|
||||||
|
return {"files": files}
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
raise HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/list/{flow_id}")
|
@router.get("/list/{flow_id}")
|
||||||
async def list_files(
|
async def list_files(
|
||||||
flow_id: UUID = Depends(get_flow_id), storage_service: StorageService = Depends(get_storage_service)
|
flow_id: UUID = Depends(get_flow_id), storage_service: StorageService = Depends(get_storage_service)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue