fix(avatar): cap knowledge files at 50MB
This commit is contained in:
@@ -17,7 +17,7 @@ UPLOAD_DIR = os.path.abspath(os.getenv("UPLOAD_DIR", os.path.join(BASE_DIR, "upl
|
||||
os.makedirs(UPLOAD_DIR, exist_ok=True)
|
||||
|
||||
ALLOWED_EXT = {".md", ".txt", ".pdf", ".doc", ".docx", ".xlsx"}
|
||||
MAX_UPLOAD_BYTES = 100 * 1024 * 1024
|
||||
MAX_UPLOAD_BYTES = 50 * 1024 * 1024
|
||||
UPLOAD_CHUNK_BYTES = 1024 * 1024
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ async def upload_doc(avatar_id: str, file: UploadFile = File(...), authorization
|
||||
while chunk := await file.read(UPLOAD_CHUNK_BYTES):
|
||||
file_size += len(chunk)
|
||||
if file_size > MAX_UPLOAD_BYTES:
|
||||
raise ValueError("文件不能超过 100MB")
|
||||
raise ValueError("文件不能超过 50MB")
|
||||
f.write(chunk)
|
||||
except ValueError as exc:
|
||||
if os.path.exists(path):
|
||||
|
||||
Reference in New Issue
Block a user