fix(training-pdf-import): 修复培训试题PDF导入判断题解析

This commit is contained in:
runny committed 2026-07-06 01:39:08 +08:00
1 parent 3a22df736e
commit 91758ef2b4
19 files changed
+1767 -12

No files matched your search

+19
View File
@@ -88,6 +88,25 @@ class MinioService:
base_url = cfg.MINIO_PUBLIC_BASE_URL.rstrip('/')
return f"{base_url}/{self.bucket_name}/{object_name}"
def get_file_bytes(self, object_name: str) -> bytes:
"""
读取对象的原始字节内容。
用途:给后台解析 PDF、图片等资料时复用统一文件读取入口,避免业务层自己判断本地回退还是 MinIO。
参数约束:object_name 必须是已存储的对象名,不接受外部 URL。
"""
local_path = os.path.join('data/agent-guides', object_name)
if os.path.exists(local_path):
with open(local_path, 'rb') as file_obj:
return file_obj.read()
response = self.client.get_object(self.bucket_name, object_name)
try:
return response.read()
finally:
response.close()
response.release_conn()
def delete_file(self, object_name: str):
try:
self.client.remove_object(self.bucket_name, object_name)