feat: Return the cleaned filename in the import project service response.

main
Cizz22 3 weeks ago
parent 42a289ffcb
commit ef702047e4

@ -18,7 +18,7 @@ from .service import import_aro_project, fetch_aro_record, reset_project, create
router = APIRouter() router = APIRouter()
@router.post("", response_model=StandardResponse[None]) @router.post("", response_model=StandardResponse[str])
async def import_aro( async def import_aro(
db_session: DbSession, db_session: DbSession,
current_user: CurrentUser, current_user: CurrentUser,
@ -38,7 +38,7 @@ async def import_aro(
result = await import_aro_project(db_session=db_session, aeros_project_in=aeros_project_input) result = await import_aro_project(db_session=db_session, aeros_project_in=aeros_project_input)
return {"data": None, "status": "success", "message": "Success"} return {"data": result, "status": "success", "message": "Success"}
@router.get("/download") @router.get("/download")

@ -41,7 +41,7 @@ async def import_aro_project(*, db_session: DbSession, aeros_project_in: AerosPr
status_code=400, status_code=400,
detail=f"Invalid filename: {str(e)}" detail=f"Invalid filename: {str(e)}"
) )
# Check if mime type is application/octet-stream # Check if mime type is application/octet-stream
if file.content_type != "application/octet-stream": if file.content_type != "application/octet-stream":
raise HTTPException( raise HTTPException(
@ -65,6 +65,7 @@ async def import_aro_project(*, db_session: DbSession, aeros_project_in: AerosPr
print("read file") print("read file")
# Read and check file size # Read and check file size
content = await file.read() content = await file.read()
if len(content) > MAX_FILE_SIZE: if len(content) > MAX_FILE_SIZE:
@ -98,6 +99,8 @@ async def import_aro_project(*, db_session: DbSession, aeros_project_in: AerosPr
) )
return clean_filename
# Project name hardcode # Project name hardcode
# project_name = "trialapi" # project_name = "trialapi"

Loading…
Cancel
Save