Spaces:
Sleeping
Sleeping
Upload main.py with huggingface_hub
Browse files
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 |
-
|
| 71 |
-
|
| 72 |
-
|
| 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 |
|