fix(assets): add project_id to OSS direct upload and align size limit to 2048MB
P1: prepareDirectUpload and completeDirectUpload now require project_id, uploadAssetDirect calls getOrCreateDefaultProject() to obtain it automatically. P2: MAX_FILE_SIZE changed from 2*1024^3 to 2048*1024*1024 to align with backend OSS_DIRECT_UPLOAD_MAX_MB=2000.
This commit is contained in:
@@ -154,6 +154,7 @@ export const uploadAsset = async (
|
||||
|
||||
/** 预签名直传准备 */
|
||||
export const prepareDirectUpload = async (data: {
|
||||
project_id: string;
|
||||
library_id: string;
|
||||
filename: string;
|
||||
content_type: string;
|
||||
@@ -172,6 +173,7 @@ export const prepareDirectUpload = async (data: {
|
||||
|
||||
/** 直传完成确认 */
|
||||
export const completeDirectUpload = async (data: {
|
||||
project_id: string;
|
||||
library_id: string;
|
||||
storage_key: string;
|
||||
}): Promise<{ storage_key: string; ingest_job_id: string }> => {
|
||||
@@ -184,7 +186,11 @@ export const uploadAssetDirect = async (data: {
|
||||
file: File;
|
||||
library_id: string;
|
||||
}): Promise<{ storage_key: string; ingest_job_id: string }> => {
|
||||
// 后端要求 project_id,前端自动获取默认项目
|
||||
const project = await getOrCreateDefaultProject();
|
||||
|
||||
const prepared = await prepareDirectUpload({
|
||||
project_id: project.id,
|
||||
library_id: data.library_id,
|
||||
filename: data.file.name,
|
||||
content_type: data.file.type || 'application/octet-stream',
|
||||
@@ -206,6 +212,7 @@ export const uploadAssetDirect = async (data: {
|
||||
}
|
||||
|
||||
return completeDirectUpload({
|
||||
project_id: project.id,
|
||||
library_id: data.library_id,
|
||||
storage_key: prepared.storage_key,
|
||||
});
|
||||
|
||||
@@ -44,8 +44,8 @@ import { getOrCreateDefaultProject } from '@/api/projects';
|
||||
const { Title, Text } = Typography;
|
||||
const { Dragger } = Upload;
|
||||
|
||||
/** 最大文件大小:2GB */
|
||||
const MAX_FILE_SIZE = 2 * 1024 * 1024 * 1024; // 2147483648 bytes
|
||||
/** 最大文件大小:2048MB(与后端 OSS_DIRECT_UPLOAD_MAX_MB=2000 对齐,留少量余量) */
|
||||
const MAX_FILE_SIZE = 2048 * 1024 * 1024; // 2147483648 bytes
|
||||
/** 大文件阈值:100MB,超过此值走 OSS 直传通道 */
|
||||
const LARGE_FILE_THRESHOLD = 100 * 1024 * 1024; // 104857600 bytes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user