zhalice2011 commited on
Commit
953beda
·
verified ·
1 Parent(s): a4529e6

Upload main.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. main.py +4 -4
main.py CHANGED
@@ -55,7 +55,7 @@ def _resize_to_thumbnail(src: Path, dest: Path):
55
 
56
 
57
  async def _upload_image(file_path: Path, filename: str, api_url: str, api_key: str) -> str | None:
58
- """Upload an image file to asset-service and return its file URL."""
59
  if not file_path.exists():
60
  return None
61
  async with httpx.AsyncClient(timeout=60) as client:
@@ -67,9 +67,9 @@ async def _upload_image(file_path: Path, filename: str, api_url: str, api_key: s
67
  data={"type": "image", "title": filename, "app": "media_processor"},
68
  )
69
  if resp.status_code in (200, 201):
70
- asset_id = resp.json().get("asset", {}).get("id")
71
- if asset_id:
72
- return f"{api_url}/api/assets/{asset_id}/file"
73
  return None
74
 
75
 
 
55
 
56
 
57
  async def _upload_image(file_path: Path, filename: str, api_url: str, api_key: str) -> str | None:
58
+ """Upload an image file to asset-service and return its file URL (with filename)."""
59
  if not file_path.exists():
60
  return None
61
  async with httpx.AsyncClient(timeout=60) as client:
 
67
  data={"type": "image", "title": filename, "app": "media_processor"},
68
  )
69
  if resp.status_code in (200, 201):
70
+ asset = resp.json().get("asset", {})
71
+ # Use the url from response directly (already has filename in path)
72
+ return asset.get("url") or asset.get("asset_details", {}).get("url")
73
  return None
74
 
75