Skip to content

Commit 61cf5fb

Browse files
Allow filename change via metadat title (#2219)
1 parent bdc7675 commit 61cf5fb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

py/core/main/api/v3/documents_router.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,13 +454,16 @@ async def create_document(
454454
if file:
455455
file_data = await self._process_file(file)
456456

457-
if not file.filename:
457+
if metadata.get("title"):
458+
file_data["filename"] = metadata["title"]
459+
460+
if not file_data["filename"]:
458461
raise R2RException(
459462
status_code=422,
460463
message="Uploaded file must have a filename.",
461464
)
462465

463-
file_ext = file.filename.split(".")[
466+
file_ext = file_data["filename"].split(".")[
464467
-1
465468
] # e.g. "pdf", "txt"
466469
max_allowed_size = await self.services.management.get_max_upload_size_by_type(

0 commit comments

Comments
 (0)