mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
fix(wechat): fix voice upload file handle and Content-Type issues (#5951)
This commit is contained in:
@@ -419,18 +419,23 @@ class WeChat:
|
|||||||
media_type=media_type,
|
media_type=media_type,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
|
# Read file content into memory to avoid file handle issues
|
||||||
with media_path.open("rb") as media_file:
|
with media_path.open("rb") as media_file:
|
||||||
response = RequestUtils(timeout=60).request(
|
file_content = media_file.read()
|
||||||
method="post",
|
|
||||||
url=req_url,
|
# Use RequestUtils with Accept header to avoid Content-Type conflicts
|
||||||
files={
|
response = RequestUtils(timeout=60).request(
|
||||||
"media": (
|
method="post",
|
||||||
media_path.name,
|
url=req_url,
|
||||||
media_file,
|
headers={"Accept": "application/json"},
|
||||||
"voice/amr" if media_type == "voice" else "application/octet-stream",
|
files={
|
||||||
)
|
"media": (
|
||||||
},
|
media_path.name,
|
||||||
)
|
file_content,
|
||||||
|
"voice/amr" if media_type == "voice" else "application/octet-stream",
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error(f"上传企业微信临时素材失败:{err}")
|
logger.error(f"上传企业微信临时素材失败:{err}")
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user