* zin: add chunk index and total.

This commit is contained in:
dingyongliang
2023-08-23 16:56:59 +08:00
parent 523d000338
commit 67414bc995
+7 -2
View File
@@ -1065,10 +1065,11 @@
return chunks;
};
const uploadChunk = (url, chunk) => {
const uploadChunk = (url, chunk, headers) => {
return fetch(url, {
method: 'POST',
body: chunk,
headers,
}).then(response => response.json());
}
@@ -1077,7 +1078,11 @@
const promises = [];
for (let i = 0; i < chunks.length; i++) {
promises.push(uploadChunk(url, chunks[i]));
const headers = {
'X-Chunk-Index': chunkIndex,
'X-Total-Chunks': totalChunks,
};
promises.push(uploadChunk(url, chunks[i], headers));
}
return Promise.all(promises);