save code

This commit is contained in:
xsl
2026-02-27 22:56:59 +08:00
parent 73e356def7
commit 339e7dc1f6
5 changed files with 207 additions and 16 deletions
+6 -4
View File
@@ -255,10 +255,10 @@ def image_to_base64(file_path, mime_type=None):
def upload_to_oss(image_path, object_name=None):
# 配置信息(替换为你的实际信息)
access_key_id = 'LTAI5tB9t2RH6f1drSLvVLLZ'
access_key_secret = '91uzPI1RAFHN7n3Y6TJDGFP8w0dG1R'
access_key_id = 'LTAI5tGp1sLzedqxihcNC1eb'
access_key_secret = 'IFZE1b8YYreCP6zfA6GaZ9uBT678qO'
endpoint = 'oss-cn-beijing.aliyuncs.com' # 替换为你的Endpoint
bucket_name = 'llyz'
bucket_name = 'xiangsilian'
# 创建Bucket实例
auth = oss2.Auth(access_key_id, access_key_secret)
@@ -300,7 +300,7 @@ def process_change_cloth(human_filename, cloth_filename, output_format, img_url,
upload_to_oss(jpg_path_name, jpg_name) # 第二个参数可选,指定OSS上的路径
https_url = f'https://llyz.oss-cn-beijing.aliyuncs.com/{jpg_name}'
https_url = f'https://xiangsilian.oss-cn-beijing.aliyuncs.com/{jpg_name}'
print(f"生成的HTTPS URL: {https_url}")
if 'base64' in output_format:
@@ -394,6 +394,7 @@ def save_image_from_url(image_url):
def change_cloth():
"""从 URL 下载图片"""
data = request.json
print(f"change_cloth data: {data}")
is_generated = data.get("is_generated")
# if not is_generated:
@@ -406,6 +407,7 @@ def change_cloth():
if not human_url:
return jsonify({"error": "Missing 'human_url' parameter"}), 400
human_filename = save_image_from_url(human_url)
if not human_filename:
return jsonify({"error": "Failed to download or save human image"}), 500