From 73aee97be5539a6470cc088db7cb88d395de219d Mon Sep 17 00:00:00 2001 From: Eternity <1533512157@qq.com> Date: Fri, 13 Mar 2026 16:46:03 +0800 Subject: [PATCH] fix(multimodel): handle 302 redirect when downloading files --- api/app/services/audio_transcription_service.py | 2 +- api/app/services/multimodal_service.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/app/services/audio_transcription_service.py b/api/app/services/audio_transcription_service.py index 11d13f38..8b94bbe2 100644 --- a/api/app/services/audio_transcription_service.py +++ b/api/app/services/audio_transcription_service.py @@ -75,7 +75,7 @@ class AudioTranscriptionService: try: # 下载音频文件 async with httpx.AsyncClient(timeout=60.0) as client: - audio_response = await client.get(audio_url) + audio_response = await client.get(audio_url, follow_redirects=True) audio_response.raise_for_status() audio_data = audio_response.content diff --git a/api/app/services/multimodal_service.py b/api/app/services/multimodal_service.py index 935efafe..b30b48b2 100644 --- a/api/app/services/multimodal_service.py +++ b/api/app/services/multimodal_service.py @@ -130,7 +130,7 @@ class BedrockFormatStrategy(MultimodalFormatStrategy): # 下载图片 if content is None: async with httpx.AsyncClient(timeout=30.0) as client: - response = await client.get(url) + response = await client.get(url, follow_redirects=True) response.raise_for_status() content = response.content self.file.set_content(content) @@ -236,7 +236,7 @@ class OpenAIFormatStrategy(MultimodalFormatStrategy): audio_data = content if content is None: async with httpx.AsyncClient(timeout=30.0) as client: - response = await client.get(url) + response = await client.get(url, follow_redirects=True) response.raise_for_status() audio_data = response.content self.file.set_content(audio_data) @@ -566,7 +566,7 @@ class MultimodalService: file_content = file.get_content() if not file_content: async with httpx.AsyncClient(timeout=30.0) as client: - response = await client.get(file.url) + response = await client.get(file.url, follow_redirects=True) response.raise_for_status() file_content = response.content file.set_content(file_content)