fix(avatar): 异步知识库索引并修复大文件上传 #16
@@ -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)
|
os.makedirs(UPLOAD_DIR, exist_ok=True)
|
||||||
|
|
||||||
ALLOWED_EXT = {".md", ".txt", ".pdf", ".doc", ".docx", ".xlsx"}
|
ALLOWED_EXT = {".md", ".txt", ".pdf", ".doc", ".docx", ".xlsx"}
|
||||||
MAX_UPLOAD_BYTES = 10 * 1024 * 1024
|
MAX_UPLOAD_BYTES = 20 * 1024 * 1024
|
||||||
|
|
||||||
|
|
||||||
class QAIn(BaseModel):
|
class QAIn(BaseModel):
|
||||||
@@ -82,7 +82,7 @@ async def upload_doc(avatar_id: str, file: UploadFile = File(...), authorization
|
|||||||
path = os.path.join(avatar_dir, stored)
|
path = os.path.join(avatar_dir, stored)
|
||||||
content = await file.read()
|
content = await file.read()
|
||||||
if len(content) > MAX_UPLOAD_BYTES:
|
if len(content) > MAX_UPLOAD_BYTES:
|
||||||
return fail("文件不能超过 10MB", code=400)
|
return fail("文件不能超过 20MB", code=400)
|
||||||
with open(path, "wb") as f:
|
with open(path, "wb") as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
doc = KnowledgeDoc(
|
doc = KnowledgeDoc(
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ http {
|
|||||||
|
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
index index.html;
|
index index.html;
|
||||||
|
# Keep the application gateway aligned with the production edge gateway.
|
||||||
|
# Without this Nginx rejects ordinary PDF uploads with HTTP 413 before
|
||||||
|
# FastAPI can return its user-facing file-size validation message.
|
||||||
|
client_max_body_size 20m;
|
||||||
|
|
||||||
# SPA 兜底(hash 路由下深链接也可正常加载)
|
# SPA 兜底(hash 路由下深链接也可正常加载)
|
||||||
location / {
|
location / {
|
||||||
|
|||||||
Reference in New Issue
Block a user