This commit is contained in:
zcr
2026-04-13 11:36:10 +08:00
parent f4670217d1
commit e670609f8e
3 changed files with 81 additions and 83 deletions

9
utils/new_oss_client.py Normal file → Executable file
View File

@@ -76,7 +76,7 @@ def upload_bytes(data_bytes, object_name, content_type):
return f"{MINIO_BUCKET}/{object_name}"
def upload_local_file(file_path, object_name, content_type="application/octet-stream"):
def upload_local_file(file_path, minio_path, content_type="application/octet-stream"):
"""
将本地磁盘上的文件上传到 MinIO
:param file_path: 本地文件路径 (如: 'output/sample.obj')
@@ -88,14 +88,15 @@ def upload_local_file(file_path, object_name, content_type="application/octet-st
raise FileNotFoundError(f"本地文件未找到: {file_path}")
# 使用 fput_object 直接从磁盘流式上传,不占用过多内存
bucket, object_name = minio_path.split('/', 1)
minio_client.fput_object(
bucket_name=MINIO_BUCKET,
bucket_name=bucket,
object_name=object_name,
file_path=file_path,
content_type=content_type
)
return f"{MINIO_BUCKET}/{object_name}"
return f"{bucket}/{object_name}"
def download_from_minio(object_path, local_path):