fix: 克隆音色上传补充 project_id/library_id 修复 422 错误
CI/CD Pipeline / Frontend Lint (push) Failing after 20s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 33s
CI/CD Pipeline / Validate Code Quality And Tests (push) Successful in 11m1s
CI/CD Pipeline / Integration Tests (push) Waiting to run
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 11m20s
CI/CD Pipeline / Integration Tests (pull_request) Waiting to run
CI/CD Pipeline / Unit Tests (push) Failing after 12m3s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 11m49s
CI Build & Deploy Pipeline / Build Staging Worker Image (pull_request) Failing after 1199h15m48s
CI Build & Deploy Pipeline / Build Staging API Image (pull_request) Failing after 1199h15m49s
CI Build & Deploy Pipeline / Build Staging Worker Image (push) Failing after 1199h16m13s
CI Build & Deploy Pipeline / Build Staging Web Image (push) Failing after 1199h16m15s
CI Build & Deploy Pipeline / Build Staging API Image (push) Failing after 1199h16m17s
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been cancelled
CI Build & Deploy Pipeline / Staging E2E Tests (pull_request) Has been cancelled
CI Build & Deploy Pipeline / Staging API Integration Tests (pull_request) Has been cancelled
CI Build & Deploy Pipeline / Build Production API Image (pull_request) Has been cancelled
CI Build & Deploy Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI Build & Deploy Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI Build & Deploy Pipeline / Deploy Production (pull_request) Has been cancelled
CI Build & Deploy Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been cancelled
CI Build & Deploy Pipeline / Staging E2E Tests (push) Has been cancelled
CI Build & Deploy Pipeline / Staging API Integration Tests (push) Has been cancelled
CI Build & Deploy Pipeline / Build Production API Image (push) Has been cancelled
CI Build & Deploy Pipeline / Build Production Web Image (push) Has been cancelled
CI Build & Deploy Pipeline / Build Production Worker Image (push) Has been cancelled
CI Build & Deploy Pipeline / Deploy Production (push) Has been cancelled
CI Build & Deploy Pipeline / Production Browser E2E (push) Has been cancelled
CI Build & Deploy Pipeline / Build Staging Web Image (pull_request) Failing after 1199h48m45s

后端 POST /upload 接口要求 FormData 必须包含 project_id 和 library_id,
克隆音色弹窗只传了 file 导致 422 Unprocessable Entity。

修复:上传前调用 getOrCreateDefaultProject() 和 ensureDefaultLibrary()
获取默认项目和 voice 素材库,追加到 FormData。
This commit is contained in:
xiaoxia
2026-07-28 15:26:56 +08:00
parent b8dbdb9fd8
commit 277e46de4b
+8 -1
View File
@@ -14,7 +14,8 @@ import React, { useState, useCallback, useRef, useEffect } from "react";
import { Modal, Button } from "@/components/ui";
import { createVoiceClone, toVoiceClone } from "@/api/voiceClone";
import type { VoiceClone } from "@/api/voiceClone";
import { uploadAsset } from "@/api/assets";
import { uploadAsset, ensureDefaultLibrary } from "@/api/assets";
import { getOrCreateDefaultProject } from "@/api/projects";
import "./clone-modal.css";
/* ── 类型定义 ───────────────────────────────────────────── */
@@ -334,8 +335,14 @@ const CloneModal: React.FC<CloneModalProps> = ({
);
}
// 获取默认项目和素材库(后端 /upload 接口必填)
const project = await getOrCreateDefaultProject();
const library = await ensureDefaultLibrary({ project_id: project.id, kind: "voice" });
const formData = new FormData();
formData.append("file", fileToUpload);
formData.append("project_id", project.id);
formData.append("library_id", library.id);
const uploadResult = await uploadAsset(formData);
// 阶段 2:克隆