tingwu_new
All checks were successful
Deploy to Server / deploy (push) Successful in 19s

This commit is contained in:
jeremygan2021
2026-03-11 22:15:12 +08:00
parent 758eee8ac6
commit cb10c42d11
3 changed files with 21 additions and 10 deletions

View File

@@ -82,6 +82,7 @@ class TranscriptionTaskViewSet(viewsets.ModelViewSet):
"""
file_obj = request.FILES.get('file')
file_url = request.data.get('file_url')
project_id = request.data.get('project_id')
if not file_obj and not file_url:
return Response({'error': '请提供文件或文件URL'}, status=status.HTTP_400_BAD_REQUEST)
@@ -104,10 +105,17 @@ class TranscriptionTaskViewSet(viewsets.ModelViewSet):
oss_url = file_url
# 2. 创建数据库记录
task_record = TranscriptionTask.objects.create(
file_url=oss_url,
status=TranscriptionTask.Status.PENDING
)
task_data = {
'file_url': oss_url,
'status': TranscriptionTask.Status.PENDING
}
if project_id:
try:
task_data['project_id'] = int(project_id)
except (ValueError, TypeError):
pass # Ignore invalid project_id
task_record = TranscriptionTask.objects.create(**task_data)
# 3. 调用听悟接口创建任务
try: