fix: 预上传导致切片实效
This commit is contained in:
@@ -74,7 +74,6 @@ export function usePresignedUpload() {
|
||||
const isError = computed(() => presignStatus.value === PRESIGN_UPLOAD_STATUS.ERROR)
|
||||
const currentMode = computed<PresignUploadMode | null>(() => uploadSession.value?.mode ?? null)
|
||||
|
||||
|
||||
/**
|
||||
* 文件大小验证
|
||||
*/
|
||||
@@ -144,7 +143,6 @@ export function usePresignedUpload() {
|
||||
alertStore.showAlert(errorMessage.value, 'error')
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化上传会话
|
||||
*/
|
||||
@@ -224,7 +222,6 @@ export function usePresignedUpload() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 代理模式上传
|
||||
*/
|
||||
@@ -263,30 +260,19 @@ export function usePresignedUpload() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件(主入口方法)
|
||||
* 根据 mode 自动选择直传或代理上传
|
||||
*/
|
||||
const uploadFile = async (
|
||||
file: File,
|
||||
options?: PresignUploadOptions
|
||||
): Promise<string | null> => {
|
||||
// 重置状态
|
||||
const uploadFile = async (file: File, options?: PresignUploadOptions): Promise<string | null> => {
|
||||
reset()
|
||||
|
||||
// 验证文件大小
|
||||
if (!validateFileSize(file)) {
|
||||
presignStatus.value = PRESIGN_UPLOAD_STATUS.ERROR
|
||||
return null
|
||||
}
|
||||
|
||||
// 初始化上传会话
|
||||
const session = await initUploadSession(file, options)
|
||||
if (!session) {
|
||||
return null
|
||||
}
|
||||
|
||||
// 根据模式选择上传方式
|
||||
if (session.mode === 'direct') {
|
||||
return await uploadDirect(file, session, options)
|
||||
} else {
|
||||
@@ -294,7 +280,6 @@ export function usePresignedUpload() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 取消上传
|
||||
*/
|
||||
|
||||
@@ -179,7 +179,6 @@ export interface RouteConfig {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ==================== 预签名上传相关类型 ====================
|
||||
|
||||
// 预签名上传模式
|
||||
|
||||
@@ -1029,16 +1029,10 @@ const handleSubmit = async () => {
|
||||
let response: ApiResponse
|
||||
|
||||
if (sendType.value === 'file') {
|
||||
// 优先使用预签名上传,如果失败则回退到其他方式
|
||||
try {
|
||||
if (config.enableChunk) {
|
||||
response = await handleChunkUpload(selectedFile.value!)
|
||||
} else {
|
||||
response = await handlePresignedUpload(selectedFile.value!)
|
||||
} catch {
|
||||
// 预签名上传失败,回退到切片上传或默认上传
|
||||
if (config.enableChunk) {
|
||||
response = await handleChunkUpload(selectedFile.value!)
|
||||
} else {
|
||||
response = await handleDefaultFileUpload(selectedFile.value!)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 文本上传保持不变
|
||||
|
||||
Reference in New Issue
Block a user