mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-19 03:05:24 -04:00
fix(upload): configure chat attachment size limit (#2439)
This commit is contained in:
@@ -12,6 +12,10 @@ import threading
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Dict, Any, Optional
|
||||
from fastapi import HTTPException, UploadFile
|
||||
|
||||
from src.upload_limits import format_byte_limit, get_chat_upload_max_bytes
|
||||
|
||||
|
||||
def secure_filename(filename: str) -> str:
|
||||
"""Sanitize a filename (replaces werkzeug.utils.secure_filename)."""
|
||||
import unicodedata
|
||||
@@ -73,7 +77,7 @@ class UploadHandler:
|
||||
def __init__(self, base_dir: str, upload_dir: str):
|
||||
self.base_dir = base_dir
|
||||
self.upload_dir = upload_dir
|
||||
self.max_upload_size = 10 * 1024 * 1024 # 10MB
|
||||
self.max_upload_size = get_chat_upload_max_bytes()
|
||||
self.max_concurrent_uploads = 3
|
||||
self.cleanup_days = 30
|
||||
# Per-IP per-minute cap. save_upload() counts EACH file, and the chat
|
||||
@@ -518,7 +522,7 @@ class UploadHandler:
|
||||
if file_size > self.max_upload_size:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail=f"File size exceeds {self.max_upload_size/1024/1024}MB limit"
|
||||
detail=f"File size exceeds {format_byte_limit(self.max_upload_size)} limit"
|
||||
)
|
||||
|
||||
# Get original filename and sanitize it
|
||||
|
||||
Reference in New Issue
Block a user