mirror of
https://github.com/lanqian528/chat2api.git
synced 2026-06-13 21:02:46 +08:00
⭐优化消息里的URL访问出错导致消息无法进行的BUG
This commit is contained in:
parent
58c60811f3
commit
4ff7e72190
@ -15,7 +15,8 @@ async def get_file_content(url):
|
||||
client = Client()
|
||||
try:
|
||||
r = await client.get(url)
|
||||
r.raise_for_status()
|
||||
if r.status_code != 200:
|
||||
return None, None
|
||||
file_content = r.content
|
||||
mime_type = r.headers.get('Content-Type', '').split(';')[0].strip()
|
||||
return file_content, mime_type
|
||||
|
||||
@ -410,6 +410,9 @@ class ChatService:
|
||||
return False
|
||||
|
||||
async def upload_file(self, file_content, mime_type):
|
||||
if not file_content or not mime_type:
|
||||
return None
|
||||
|
||||
width, height = None, None
|
||||
if mime_type.startswith("image/"):
|
||||
try:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user