Skip to content

Commit

Permalink
Add response for successful file upload (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanaysoni authored Jul 6, 2020
1 parent 0eb8a29 commit 68d604d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ coverage
langdetect # for PDF conversions
# optional: sentence-transformers
#temporarily (used for DPR downloads)
wget
wget
python-multipart
4 changes: 2 additions & 2 deletions rest_api/controller/file_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def upload_file_to_document_store(
remove_empty_lines: Optional[bool] = Form(REMOVE_EMPTY_LINES),
remove_header_footer: Optional[bool] = Form(REMOVE_HEADER_FOOTER),
valid_languages: Optional[List[str]] = Form(VALID_LANGUAGES),
) -> None:
):
try:
file_path = Path(FILE_UPLOAD_PATH) / f"{uuid.uuid4().hex}_{file.filename}"
with file_path.open("wb") as buffer:
Expand Down Expand Up @@ -78,6 +78,6 @@ def upload_file_to_document_store(

document = {TEXT_FIELD_NAME: "\n".join(pages), "name": file.filename}
document_store.write_documents([document])

return "File upload was successful."
finally:
file.file.close()

0 comments on commit 68d604d

Please sign in to comment.