Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions extralit-server/src/extralit_server/contexts/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand All @@ -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

Expand Down
8 changes: 7 additions & 1 deletion extralit-server/tests/unit/contexts/test_files_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/")
Expand Down
Loading