加入类型转换逻辑,防止解码失败
This commit is contained in:
@@ -407,7 +407,10 @@ def api_preview_task(task_id):
|
||||
|
||||
# 发送语音消息
|
||||
if task.get('content_voice'):
|
||||
send_message_in_thread(server.client.send_voice_message, recipient, Path(task['content_voice']))
|
||||
voice_path = Path(task['content_voice'])
|
||||
# 根据文件扩展名确定类型
|
||||
voice_type = 'wav' if voice_path.suffix.lower() == '.wav' else 'mp3'
|
||||
send_message_in_thread(server.client.send_voice_message, recipient, voice_path, voice_type)
|
||||
|
||||
# 发送视频消息
|
||||
if task.get('content_video'):
|
||||
@@ -538,10 +541,12 @@ def upload_file():
|
||||
file_type = 'video'
|
||||
|
||||
if file and allowed_file(file.filename, file_type):
|
||||
# 生成安全的文件名
|
||||
filename = secure_filename(file.filename)
|
||||
# 生成唯一文件名
|
||||
unique_filename = f"{uuid.uuid4().hex}_{filename}"
|
||||
# 获取原始文件名和扩展名
|
||||
original_filename = secure_filename(file.filename)
|
||||
file_ext = original_filename.rsplit('.', 1)[1].lower()
|
||||
|
||||
# 生成唯一文件名,保持原始扩展名
|
||||
unique_filename = f"{uuid.uuid4().hex}.{file_ext}"
|
||||
|
||||
# 确保上传目录存在
|
||||
upload_folder = os.path.join(current_app.root_path, 'static', 'uploads')
|
||||
|
||||
Reference in New Issue
Block a user