File size: 379 Bytes
195b80e
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
# utils/file_limits.py
from app.core.context import GlobalSessionContext

MAX_SESSION_UPLOAD_SIZE_MB = 10


MAX_TOTAL_UPLOAD_MB = 10

def is_within_upload_limit(session_id: str, new_file_bytes: bytes, session_context: GlobalSessionContext) -> bool:
    size_mb = (session_context.total_upload_size + len(new_file_bytes)) / (1024 * 1024)
    return size_mb <= MAX_TOTAL_UPLOAD_MB