mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
fix: Support signed URLs with query parameters for Vertex AI Gemini (#17976)
- Fix _get_image_mime_type_from_url() to parse path without query params - Resolves issues with Tencent Cloud COS and other signed URLs
This commit is contained in:
parent
636efb7795
commit
0eb7d975a1
1 changed files with 8 additions and 1 deletions
|
|
@ -689,7 +689,14 @@ def _get_image_mime_type_from_url(url: str) -> Optional[str]:
|
|||
video/mpegps
|
||||
video/flv
|
||||
"""
|
||||
from urllib.parse import urlparse
|
||||
|
||||
url = url.lower()
|
||||
|
||||
# Parse URL to extract path without query parameters
|
||||
# This handles URLs like: https://example.com/image.jpg?signature=...
|
||||
parsed = urlparse(url)
|
||||
path = parsed.path
|
||||
|
||||
# Map file extensions to mime types
|
||||
mime_types = {
|
||||
|
|
@ -717,7 +724,7 @@ def _get_image_mime_type_from_url(url: str) -> Optional[str]:
|
|||
|
||||
# Check each extension group against the URL
|
||||
for extensions, mime_type in mime_types.items():
|
||||
if any(url.endswith(ext) for ext in extensions):
|
||||
if any(path.endswith(ext) for ext in extensions):
|
||||
return mime_type
|
||||
|
||||
return None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue