fix: configurable internal API URL and upload size enforcement
H4: add internal_api_base_url setting to config.py (default http://localhost:8888, env-overridable via INTERNAL_API_BASE_URL); replace all 5 hardcoded base_url strings in chat_service.py. H6: add post-read size check in both Excel and STEP upload handlers; raises HTTP 413 when content exceeds settings.max_upload_size_mb. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -107,6 +107,9 @@ async def upload_excel(
|
||||
tmp_path = upload_dir / tmp_name
|
||||
|
||||
content = await file.read()
|
||||
max_bytes = settings.max_upload_size_mb * 1024 * 1024
|
||||
if len(content) > max_bytes:
|
||||
raise HTTPException(413, detail=f"File exceeds maximum upload size of {settings.max_upload_size_mb} MB")
|
||||
tmp_path.write_bytes(content)
|
||||
|
||||
try:
|
||||
@@ -408,6 +411,9 @@ async def upload_step(
|
||||
raise HTTPException(400, detail="Only .stp / .step files are accepted")
|
||||
|
||||
content = await file.read()
|
||||
max_bytes = settings.max_upload_size_mb * 1024 * 1024
|
||||
if len(content) > max_bytes:
|
||||
raise HTTPException(413, detail=f"File exceeds maximum upload size of {settings.max_upload_size_mb} MB")
|
||||
file_hash = hashlib.sha256(content).hexdigest()
|
||||
|
||||
# Check dedup
|
||||
|
||||
Reference in New Issue
Block a user