-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add site setting upload_max_body_size #497
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@sszgwdk is attempting to deploy a commit to the pingcap Team on Vercel. A member of the Team first needs to authorize it. |
if SiteSetting.setting_exists("upload_max_body_size"): | ||
sys_upload_max_body_size = SiteSetting.get_setting("upload_max_body_size") | ||
if file.size > sys_upload_max_body_size: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the __getattr__
method has been overrided,
def __getattr__(self, name: str) -> SettingType: |
You can just:
if SiteSetting.setting_exists("upload_max_body_size"): | |
sys_upload_max_body_size = SiteSetting.get_setting("upload_max_body_size") | |
if file.size > sys_upload_max_body_size: | |
sys_upload_max_body_size = SiteSetting.upload_max_body_size | |
if sys_upload_max_body_size: | |
if file.size > sys_upload_max_body_size: |
|
||
upload: | ||
upload_max_body_size: | ||
default: 10485760 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default: 10485760 | |
default: 10485760 # 10MB |
if file.size > sys_upload_max_body_size: | ||
raise HTTPException( | ||
status_code=status.HTTP_413_REQUEST_ENTITY_TOO_LARGE, | ||
detail=f"File size({file.size}) exceeds maximum allowed size({sys_upload_max_body_size})", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can me make the file size humam-readble?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest LGTM
Co-authored-by: Mini256 <[email protected]>
Co-authored-by: Mini256 <[email protected]>
Co-authored-by: Mini256 <[email protected]>
Co-authored-by: Mini256 <[email protected]>
fix bug #382