Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Add Filename Extension
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoXinYo committed Aug 15, 2023
1 parent f2c6e7d commit 191c951
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def submit() -> Response:
return core.GenerateResponse().error(110, 'parameter cannot be empty')

targetFormat = target.filename.split('.')[-1]
if targetFormat not in ['png', 'jpg', 'mp4']:
targetFormat = targetFormat.lower()
if targetFormat not in ['png', 'jpeg', 'jpg', 'mp4']:
return core.GenerateResponse().error(110, 'the target file format is not supported')
elif target.content_length > config.INPUT_FILE_MAX_SIZE * 1024:
return core.GenerateResponse().error(110, 'the target file size exceeds the max limit')
Expand All @@ -44,7 +45,8 @@ def submit() -> Response:
if not source:
return core.GenerateResponse().error(110, 'parameter cannot be empty')
sourceFormat = source.filename.split('.')[-1]
if sourceFormat not in ['png', 'jpg']:
sourceFormat = sourceFormat.lower()
if sourceFormat not in ['png', 'jpeg', 'jpg']:
return core.GenerateResponse().error(110, 'the source file format is not supported')
elif source.content_length > config.INPUT_FILE_MAX_SIZE * 1024:
return core.GenerateResponse().error(110, 'the source file size exceeds the max limit')
Expand Down

0 comments on commit 191c951

Please sign in to comment.