diff --git a/package.json b/package.json index 4bb1906..3946165 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kevisual/api", - "version": "0.0.37", + "version": "0.0.38", "description": "", "main": "mod.ts", "scripts": { diff --git a/query/query-resources/index.ts b/query/query-resources/index.ts index b9a1626..c140c6b 100644 --- a/query/query-resources/index.ts +++ b/query/query-resources/index.ts @@ -107,7 +107,7 @@ export class QueryResources { const filename = path.basename(pathname); const url = new URL(pathname, window.location.origin); url.searchParams.set('hash', hash); - url.searchParams.set('chunked', '1'); + url.searchParams.set('chunk', '1'); console.log(`url,`, url, hash); // 预留 eventSource 支持(暂不处理) // const createEventSource = opts?.createEventSource; @@ -118,10 +118,12 @@ export class QueryResources { for (let currentChunk = 0; currentChunk < totalChunks; currentChunk++) { const start = currentChunk * chunkSize; const end = Math.min(start + chunkSize, file.size); - const chunk = file.slice(start, end); + const chunkBlob = file.slice(start, end); + // 转换为 File 类型 + const chunkFile = new File([chunkBlob], filename, { type: file.type || 'application/octet-stream' }); const formData = new FormData(); - formData.append('file', chunk, filename); + formData.append('file', chunkFile, filename); formData.append('chunkIndex', currentChunk.toString()); formData.append('totalChunks', totalChunks.toString()); console.log(`Uploading chunk ${currentChunk + 1}/${totalChunks}`, url.toString()); @@ -136,6 +138,7 @@ export class QueryResources { headers: { ...opts?.headers, ...this.header(opts?.headers, false) }, params: { hash: hash, + chunk: '1', ...opts?.params, }, });