feat : 代码梳理 移除所有敏感密钥 通过环境变量方式配置
All checks were successful
git commit AiDA python develop 分支构建部署 / scheduled_deploy (push) Has been skipped
All checks were successful
git commit AiDA python develop 分支构建部署 / scheduled_deploy (push) Has been skipped
This commit is contained in:
@@ -2,20 +2,19 @@ import base64
|
||||
|
||||
from minio import Minio
|
||||
|
||||
from app.core.config import MINIO_URL, MINIO_ACCESS, MINIO_SECRET, MINIO_SECURE
|
||||
from app.core.config import settings
|
||||
|
||||
minio_client = Minio(MINIO_URL, access_key=MINIO_ACCESS, secret_key=MINIO_SECRET, secure=MINIO_SECURE)
|
||||
minio_client = Minio(settings.MINIO_URL, access_key=settings.MINIO_ACCESS, secret_key=settings.MINIO_SECRET, secure=settings.MINIO_SECURE)
|
||||
|
||||
|
||||
def minio_url_to_base64(minio_url: str) -> str:
|
||||
bucket_name, object_name = minio_url.split("/", 1)
|
||||
|
||||
response = minio_client.get_object(bucket_name, object_name)
|
||||
try:
|
||||
response = minio_client.get_object(bucket_name, object_name)
|
||||
image_data = response.read()
|
||||
return base64.b64encode(image_data).decode('utf-8')
|
||||
except Exception as e:
|
||||
raise RuntimeError(f"Failed to get object: {e}")
|
||||
finally:
|
||||
if 'response' in locals():
|
||||
response.close()
|
||||
response.close()
|
||||
|
||||
Reference in New Issue
Block a user