From 06a9cf2af96c700f659a7e802bc1a06e936b403b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AC=E5=8F=B8git?= <240241002@qq.com> Date: Thu, 16 Jul 2026 14:51:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BB=8E=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=85=AC=E5=85=B1=E5=9F=BA=E7=A1=80=20URL?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E8=B0=83=E6=95=B4=E6=96=87=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=8A=9F=E8=83=BD=E4=BB=A5=E4=BD=BF=E7=94=A8=E8=AF=A5?= =?UTF-8?q?=20URL=20=E7=94=9F=E6=88=90=E4=B8=8B=E8=BD=BD=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 1 + services/file_service.py | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) 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):