Skip to content

Commit

Permalink
Merge pull request #46 from ninoseki/add-file-ex-validation
Browse files Browse the repository at this point in the history
feat: add ext validation
  • Loading branch information
ninoseki committed Aug 25, 2020
2 parents e03b97a + 8e60ff1 commit 5923b07
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/api/endpoints/submit.py
Expand Up @@ -26,6 +26,15 @@ async def submit_to_inquest(attachment: Attachment) -> SubmissionResult:
status_code=403,
content=jsonable_encoder({"detail": "You don't have the InQuest API key"}),
)
# check ext type
valid_types = ["doc", "docx", "ppt", "pptx", "xls", "xlsx"]
if attachment.extension not in valid_types:
return JSONResponse(
status_code=415,
content=jsonable_encoder(
{"detail": f"{attachment.extension} is not supported."}
),
)

submitter = InQuestSubmitter(attachment)
try:
Expand Down

0 comments on commit 5923b07

Please sign in to comment.