good version for web

This commit is contained in:
2026-02-18 09:36:18 +08:00
parent 62ea5d36a5
commit 72ab0c0b56
42 changed files with 1305 additions and 1515 deletions

View File

@@ -59,6 +59,27 @@ class MinioClient:
logging.warning(f"MinIO upload error: {e}")
return False
def upload_from_bytes(self, data: bytes, object_name: str) -> bool:
"""从字节数据上传文件"""
if not self.is_connected:
logging.warning("MinIO is not connected. Upload skipped.")
return False
try:
import io
file_obj = io.BytesIO(data)
self.client.put_object(
self.bucket_name,
object_name,
file_obj,
length=len(data),
part_size=10*1024*1024
)
return True
except S3Error as e:
logging.warning(f"MinIO upload error: {e}")
return False
def upload_fileobj(self, file_obj: io.BytesIO, object_name: str, content_type: str = "application/octet-stream") -> bool:
"""上传文件对象"""
if not self.is_connected: