修复一个保存文件

This commit is contained in:
毛鹏
2025-11-26 14:51:47 +08:00
parent f983eac971
commit dc0c90452d
2 changed files with 8 additions and 3 deletions

View File

@@ -20,6 +20,8 @@ if IS_MINIO:
class SaveMinio:
_lifecycle_set = False # 类变量,跟踪是否已设置生命周期规则
def __init__(self, directory_name="screenshot"):
self.client = Minio(
MINIO_STORAGE_ENDPOINT,
@@ -51,7 +53,10 @@ class SaveMinio:
tmp_file.write(chunk)
temp_file_path = tmp_file.name
try:
self.client.set_bucket_lifecycle(MINIO_STORAGE_MEDIA_BUCKET_NAME, self.lifecycle_config)
# 只在第一次调用时设置生命周期规则
if not SaveMinio._lifecycle_set:
self.client.set_bucket_lifecycle(MINIO_STORAGE_MEDIA_BUCKET_NAME, self.lifecycle_config)
SaveMinio._lifecycle_set = True
# 上传文件到MinIO
self.client.fput_object(
MINIO_STORAGE_MEDIA_BUCKET_NAME,

View File

@@ -60,7 +60,7 @@
## 📝 版权声明
VERSION = 5.8.7
VERSION = 5.8.8
版权所有 © 2022 by 芒果味
---