66import starlette .requests
77from api .database import get_async_session , get_engine
88from api .routes .security import has_access
9+ from api .settings import settings
910from fastapi import (
1011 APIRouter ,
1112 Depends ,
1819from minio import Minio
1920from sqlalchemy import text
2021from starlette .datastructures import UploadFile as StarletteUploadFile
21- from api .settings import settings
2222
2323router = APIRouter (
2424 prefix = "/object" ,
@@ -49,6 +49,7 @@ def sha256_of_uploadfile(
4949 upload .file .seek (0 )
5050 return h .hexdigest ()
5151
52+
5253def get_s3_client ():
5354 # TODO need to add or configure these envs within api v3 kubernetes config
5455 return Minio (
@@ -58,6 +59,7 @@ def get_s3_client():
5859 secure = settings .s3_secure ,
5960 )
6061
62+
6163def get_storage_host_bucket () -> tuple [str , str ]:
6264 """
6365 Keep host/bucket consistent everywhere.
@@ -191,7 +193,6 @@ async def list_objects(
191193 return {"items" : items , "next_before_id" : next_before_id }
192194
193195
194-
195196@router .get ("/{id}" )
196197async def get_object (id : int ):
197198 engine = get_engine ()
@@ -406,6 +407,7 @@ async def delete_object(
406407 await session .commit ()
407408 return {"status" : "deleted" , "hard" : False , "object" : _row_to_dict (row2 )}
408409
410+
409411@router .post ("/{id}/track" )
410412async def track_object (id : int ):
411413 """
@@ -421,10 +423,10 @@ async def forget_object(id: int):
421423 """
422424 raise HTTPException (status_code = 501 , detail = "Forget not implemented yet" )
423425
426+
424427@router .get ("/{id}/url" )
425428async def get_object_url (id : int ):
426429 """
427430 TODO: Return or redirect to signed S3 URL.
428431 """
429432 raise HTTPException (status_code = 501 , detail = "URL helper not implemented yet" )
430-
0 commit comments