更新配置,支持从环境变量获取公共基础 URL,并调整文件上传功能以使用该 URL 生成下载链接

This commit is contained in:
公司git 2026-07-16 14:51:04 +08:00
parent 6bd8a67103
commit 06a9cf2af9
2 changed files with 4 additions and 5 deletions

View File

@ -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"

View File

@ -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):