add endpoint to download profile picture
This commit is contained in:
parent
c467cc649a
commit
08a259da86
1 changed files with 19 additions and 0 deletions
|
|
@ -100,6 +100,25 @@ async def download_image(file_name: str, flow_id: UUID, storage_service: Storage
|
|||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
@router.get("/profile_pictures/{folder_name}/{file_name}")
|
||||
async def download_profile_picture(
|
||||
folder_name: str,
|
||||
file_name: str,
|
||||
storage_service: StorageService = Depends(get_storage_service),
|
||||
):
|
||||
try:
|
||||
extension = file_name.split(".")[-1]
|
||||
config_dir = get_storage_service().settings_service.settings.config_dir
|
||||
config_path = Path(config_dir)
|
||||
folder_path = config_path / 'profile_pictures' / folder_name
|
||||
content_type = build_content_type_from_extension(extension)
|
||||
file_content = await storage_service.get_file(flow_id=folder_path, file_name=file_name)
|
||||
return StreamingResponse(BytesIO(file_content), media_type=content_type)
|
||||
|
||||
except Exception as 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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue