Merge branch 'test' into prod
This commit is contained in:
commit
ec2c9eca6f
9 files changed
+41
-15
No files matched your search
@@ -78,6 +78,8 @@ def _backend_path(env_key: str, *parts: str) -> str:
|
||||
class Config:
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
SECRET_KEY = os.getenv('SECRET_KEY')
|
||||
# 配置最大上传文件大小(200MB)
|
||||
MAX_CONTENT_LENGTH = 200 * 1024 * 1024
|
||||
KB_STORAGE_ROOT = _data_path('KB_STORAGE_ROOT', 'kb')
|
||||
KB_TASK_EXECUTION_MODE = os.getenv('KB_TASK_EXECUTION_MODE', 'worker').strip().lower()
|
||||
KB_WORKER_POLL_SECONDS = float(os.getenv('KB_WORKER_POLL_SECONDS', '2'))
|
||||
|
||||
@@ -83,8 +83,12 @@ def upload_guide_file(file_storage: FileStorage | None) -> dict:
|
||||
if not file_storage or file_storage.filename == '':
|
||||
raise ValidationError('No selected file' if file_storage else 'No file part')
|
||||
content_type = file_storage.content_type
|
||||
file_size = len(file_storage.read())
|
||||
file_storage.seek(0)
|
||||
|
||||
# 更高效地获取文件大小,不一次性读取全部内容到内存
|
||||
file_storage.seek(0, 2) # 移动到文件末尾
|
||||
file_size = file_storage.tell() # 获取当前位置(即文件大小)
|
||||
file_storage.seek(0) # 重置到文件开头
|
||||
|
||||
try:
|
||||
object_name = minio_service.upload_file(file_storage, file_storage.filename, content_type, file_size)
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user