From 89436835f8f68db312b67f23f0726eb6cde5c493 Mon Sep 17 00:00:00 2001 From: Scott Black Date: Sat, 6 Jan 2024 23:41:08 -0700 Subject: [PATCH] add presigned put url creation --- .../subsetter/app/routers/storage/router.py | 34 ++++--------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/app/api/subsetter/app/routers/storage/router.py b/app/api/subsetter/app/routers/storage/router.py index c8ef717f..640ab12d 100644 --- a/app/api/subsetter/app/routers/storage/router.py +++ b/app/api/subsetter/app/routers/storage/router.py @@ -7,7 +7,7 @@ @router.get('/presigned/get/{workflow_id}', description="Create a download url") -async def presigned_put_minio(workflow_params: WorkflowDep): +async def presigned_get_minio(workflow_params: WorkflowDep): submission = workflow_params.user.get_submission(workflow_params.workflow_id) url = get_minio_client().presigned_get_object( workflow_params.user.username, f"argo_workflows/{submission.workflow_name}/{submission.workflow_id}/all.gz" @@ -15,33 +15,11 @@ async def presigned_put_minio(workflow_params: WorkflowDep): return {'url': url} -''' -@router.post('/bucket/create') -async def create_user_bucket( - user: User = Depends(current_active_user), description="Creates a bucket named with the username" -): - if not get_minio_client().bucket_exists(user.username): - get_minio_client().make_bucket(user.username) - -@router.get('/upload/{user_name}/workflow/{workflow_id}') -async def share_workflow_with_user( - user_name: str, workflow_params: WorkflowDep, user: User = Depends(current_active_user) -): - submission: Submission = workflow_params.submission - submission.add_user(user_name) - await user.update_submission(submission) - return User.get(user.document_id) - - -@router.get('/remove/{user_name}/workflow/{workflow_id}') -async def share_workflow_with_user( - user_name: str, workflow_params: WorkflowDep, user: User = Depends(current_active_user) -): - submission: Submission = workflow_params.submission - submission.remove_user(user_name) - await user.update_submission(submission) - return User.get(document_id=user.document_id) -''' +@router.get('/presigned/put/{bucket}', description="Create a PUT file presigned url") +async def presigned_put_minio(bucket: str, path: str): + url = get_minio_client().presigned_put_object(bucket, path) + return {'url': url} + # @router.post('/extract/{workflow_id}') # async def extract_workflow_artifact(workflow_params: WorkflowDep) -> SubmissionResponseModel: