MCPcopy Index your code
hub / github.com/vastsa/FileCodeBox / validate_file_size

Function validate_file_size

apps/base/views.py:86–97  ·  view source on GitHub ↗
(file: UploadFile, max_size: int)

Source from the content-addressed store, hash-verified

84
85
86async def validate_file_size(file: UploadFile, max_size: int) -> int:
87 size = file.size
88 if size is None:
89 await file.seek(0, 2) # type: ignore[arg-type]
90 size = file.file.tell()
91 await file.seek(0)
92 if size > max_size:
93 max_size_mb = max_size / (1024 * 1024)
94 raise HTTPException(
95 status_code=403, detail=f"大小超过限制,最大为{max_size_mb:.2f} MB"
96 )
97 return size
98
99
100def normalize_allowed_file_types() -> list[str]:

Callers 2

share_fileFunction · 0.85
presign_upload_proxyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected