Spaces:
Sleeping
Sleeping
Upload main.py with huggingface_hub
Browse files54 unmodified lines555657585960615 unmodified lines67686970717273747554 unmodified linesasync def _upload_image(file_path: Path, filename: str, api_url: str, api_key: str) -> str | None:"""Upload an image file to asset-service and return its file URL."""if not file_path.exists():return Noneasync with httpx.AsyncClient(timeout=60) as client:5 unmodified linesdata={"type": "image", "title": filename, "app": "media_processor"},)if resp.status_code in (200, 201):asset_id = resp.json().get("asset", {}).get("id")if asset_id:return f"{api_url}/api/assets/{asset_id}/file"return None54 unmodified lines555657585960615 unmodified lines67686970717273747554 unmodified linesasync def _upload_image(file_path: Path, filename: str, api_url: str, api_key: str) -> str | None:"""Upload an image file to asset-service and return its file URL (with filename)."""if not file_path.exists():return Noneasync with httpx.AsyncClient(timeout=60) as client:5 unmodified linesdata={"type": "image", "title": filename, "app": "media_processor"},)if resp.status_code in (200, 201):asset = resp.json().get("asset", {})# Use the url from response directly (already has filename in path)return asset.get("url") or asset.get("asset_details", {}).get("url")return None
main.py+4-4