1
0
forked from erp-dev/erp

feat: added customContent

This commit is contained in:
2026-01-20 19:43:51 +08:00
parent 47d520aec6
commit 2147b99cbe
2 changed files with 17 additions and 13 deletions

View File

@@ -24,15 +24,6 @@ def _truncate(s: str, max_len: int) -> str:
return s
return s[:max_len]
def _default_tiia_tags_for_image_url(image_url: str) -> str:
"""
TencentCloud TIIA `Tags` is a string field; in practice people often put JSON string inside.
We store the original accessible image URL there so SearchImage results can carry it back.
"""
payload = {'imageUrl': (image_url or '').strip()}
# Keep it compact and readable.
return json.dumps(payload, ensure_ascii=False, separators=(',', ':'))
def _compute_tiia_pic_name(*, image_url: str, pic_prefix: str) -> str:
parsed = urlparse(image_url)
basename = (parsed.path.rsplit('/', 1)[-1] or '').strip()
@@ -246,10 +237,10 @@ def upload_image_url_to_tencent_tiia(*, image_url: str, entity_id: str, tags: st
req.EntityId = str(entity_id)
req.PicName = str(pic_name)
req.ImageUrl = str(image_url)
# Store accessible URL into tags so SearchImage result can carry it back.
# (UpdateImage only supports Tags, not CustomContent, so Tags is the primary field.)
req.Tags = str(tags) if tags is not None else _default_tiia_tags_for_image_url(image_url)
# Also store it in CustomContent for human readability (CreateImage supports it).
# Per product requirement: do NOT write Tags by default.
if tags is not None and str(tags).strip() != '':
req.Tags = str(tags)
# Keep CustomContent as full URL by default (CreateImage supports it).
req.CustomContent = str(custom_content) if custom_content is not None else str(image_url)
resp = client.CreateImage(req)