fix: 迁移码返回完整URL;确认须在目标店;兼容扫码接收
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -74,16 +74,17 @@ def generate_migrate_qrcode(*, to_club_id: str, token: str) -> Tuple[str, str]:
|
||||
oss_path = f"club_migrate/{club_id}/{filename}"
|
||||
file_obj = io.BytesIO(wx_resp.content)
|
||||
try:
|
||||
full_url = upload_to_oss(file_obj, oss_path)
|
||||
full_url = upload_to_oss(file_obj, oss_path, content_type='image/png')
|
||||
except Exception as e:
|
||||
logger.exception('migrate qr upload fail: %s', e)
|
||||
return '', f'上传小程序码失败: {e}'
|
||||
if not full_url:
|
||||
return '', '上传小程序码失败'
|
||||
|
||||
# 前端保存相册必须用 https 完整链;相对路径在 oss 未就绪时会保存失败
|
||||
if str(full_url).startswith('http'):
|
||||
return str(full_url), ''
|
||||
cos_domain = getattr(settings, 'COS_DOMAIN', '').rstrip('/')
|
||||
if cos_domain and full_url.startswith(cos_domain):
|
||||
relative_path = full_url.replace(f'{cos_domain}/', '', 1)
|
||||
else:
|
||||
relative_path = oss_path
|
||||
return relative_path, ''
|
||||
if cos_domain:
|
||||
return f'{cos_domain}/{str(full_url).lstrip("/")}', ''
|
||||
return str(full_url), ''
|
||||
|
||||
Reference in New Issue
Block a user