mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-06 07:56:52 +08:00
fix(wechat): fix voice upload file handle and Content-Type issues (#5951)
This commit is contained in:
@@ -419,14 +419,19 @@ 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:
|
||||||
|
file_content = media_file.read()
|
||||||
|
|
||||||
|
# Use RequestUtils with Accept header to avoid Content-Type conflicts
|
||||||
response = RequestUtils(timeout=60).request(
|
response = RequestUtils(timeout=60).request(
|
||||||
method="post",
|
method="post",
|
||||||
url=req_url,
|
url=req_url,
|
||||||
|
headers={"Accept": "application/json"},
|
||||||
files={
|
files={
|
||||||
"media": (
|
"media": (
|
||||||
media_path.name,
|
media_path.name,
|
||||||
media_file,
|
file_content,
|
||||||
"voice/amr" if media_type == "voice" else "application/octet-stream",
|
"voice/amr" if media_type == "voice" else "application/octet-stream",
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user