This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user