diff --git a/extralit-server/src/extralit_server/contexts/files.py b/extralit-server/src/extralit_server/contexts/files.py index bc2b87f21..123561f60 100644 --- a/extralit-server/src/extralit_server/contexts/files.py +++ b/extralit-server/src/extralit_server/contexts/files.py @@ -383,7 +383,7 @@ async def delete_document_artifacts(storage: ObjectStorage, workspace: str, docu async def put_document_file( storage: ObjectStorage, - workspace: str, + workspace_name: str, document_id: UUID, file_data: bytes, filename: str, @@ -399,7 +399,7 @@ async def put_document_file( object_path = get_pdf_s3_object_path(document_id) try: - existing_files = await list_objects(storage, workspace, prefix=object_path, recursive=False) + existing_files = await list_objects(storage, workspace_name, prefix=object_path, recursive=False) should_upload = True if existing_files.objects: @@ -412,9 +412,9 @@ async def put_document_file( should_upload = False if should_upload: - await _put(storage, workspace, object_path, file_data, content_type, metadata) + await _put(storage, workspace_name, object_path, file_data, content_type, metadata) - return get_proxy_document_url(workspace, object_path) + return get_proxy_document_url(workspace_name, object_path) return None diff --git a/extralit-server/tests/unit/contexts/test_files_store.py b/extralit-server/tests/unit/contexts/test_files_store.py index 78235e15c..af47a7b9b 100644 --- a/extralit-server/tests/unit/contexts/test_files_store.py +++ b/extralit-server/tests/unit/contexts/test_files_store.py @@ -178,7 +178,13 @@ class TestPutDocumentFile: async def test_the_first_upload_returns_a_proxy_url(self, storage): from uuid import uuid4 - url = await files.put_document_file(storage, WORKSPACE, uuid4(), b"%PDF-1.4", "a.pdf") + url = await files.put_document_file( + storage=storage, + workspace_name=WORKSPACE, + document_id=uuid4(), + file_data=b"%PDF-1.4", + filename="a.pdf", + ) assert url is not None assert url.startswith(f"/api/v1/file/{WORKSPACE}/pdf/")