@kevisual/api 0.0.37 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -107,7 +107,7 @@ export class QueryResources {
|
|
|
107
107
|
const filename = path.basename(pathname);
|
|
108
108
|
const url = new URL(pathname, window.location.origin);
|
|
109
109
|
url.searchParams.set('hash', hash);
|
|
110
|
-
url.searchParams.set('
|
|
110
|
+
url.searchParams.set('chunk', '1');
|
|
111
111
|
console.log(`url,`, url, hash);
|
|
112
112
|
// 预留 eventSource 支持(暂不处理)
|
|
113
113
|
// const createEventSource = opts?.createEventSource;
|
|
@@ -118,10 +118,12 @@ export class QueryResources {
|
|
|
118
118
|
for (let currentChunk = 0; currentChunk < totalChunks; currentChunk++) {
|
|
119
119
|
const start = currentChunk * chunkSize;
|
|
120
120
|
const end = Math.min(start + chunkSize, file.size);
|
|
121
|
-
const
|
|
121
|
+
const chunkBlob = file.slice(start, end);
|
|
122
|
+
// 转换为 File 类型
|
|
123
|
+
const chunkFile = new File([chunkBlob], filename, { type: file.type || 'application/octet-stream' });
|
|
122
124
|
|
|
123
125
|
const formData = new FormData();
|
|
124
|
-
formData.append('file',
|
|
126
|
+
formData.append('file', chunkFile, filename);
|
|
125
127
|
formData.append('chunkIndex', currentChunk.toString());
|
|
126
128
|
formData.append('totalChunks', totalChunks.toString());
|
|
127
129
|
console.log(`Uploading chunk ${currentChunk + 1}/${totalChunks}`, url.toString());
|
|
@@ -136,6 +138,7 @@ export class QueryResources {
|
|
|
136
138
|
headers: { ...opts?.headers, ...this.header(opts?.headers, false) },
|
|
137
139
|
params: {
|
|
138
140
|
hash: hash,
|
|
141
|
+
chunk: '1',
|
|
139
142
|
...opts?.params,
|
|
140
143
|
},
|
|
141
144
|
});
|