diff --git a/config.py b/config.py index c062d3f..c4576d8 100644 --- a/config.py +++ b/config.py @@ -3,6 +3,7 @@ import os class Config: # 基础配置 SECRET_KEY = os.getenv("SECRET_KEY", "vision-ai-secret-key") + PUBLIC_BASE_URL = os.getenv("PUBLIC_BASE_URL", "https://860576.xyz").rstrip("/") # PostgreSQL 配置 SQLALCHEMY_DATABASE_URI = "postgresql://user_xREpkJ:password_DZz8DQ@331002.xyz:2022/ai_vision" diff --git a/services/file_service.py b/services/file_service.py index ffc3c9c..adb20d7 100644 --- a/services/file_service.py +++ b/services/file_service.py @@ -19,11 +19,9 @@ def handle_file_uploads(files): f, Config.MINIO["bucket"], filename, ExtraArgs={"ContentType": f.content_type} ) - img_urls.append(f"{Config.MINIO['public_url']}{quote(filename)}") - endpoint = Config.MINIO["endpoint"].rstrip("/") - bucket = quote(Config.MINIO["bucket"], safe="") - object_key = quote(filename, safe="/") - download_urls.append(f"{endpoint}/{bucket}/{object_key}") + public_path = f"{Config.MINIO['public_url'].rstrip('/')}/{quote(filename)}" + img_urls.append(public_path) + download_urls.append(f"{Config.PUBLIC_BASE_URL}{public_path}") return img_urls, download_urls def get_remote_file_stream(url):