@uploadcare/upload-client 6.13.0 → 6.14.1-alpha.0
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/dist/cjs/index.browser.cjs +16 -13
- package/dist/cjs/index.node.cjs +16 -13
- package/dist/cjs/index.react-native.cjs +34 -15
- package/dist/esm/index.browser.mjs +16 -13
- package/dist/esm/index.node.mjs +16 -13
- package/dist/esm/index.react-native.mjs +34 -15
- package/package.json +2 -2
|
@@ -171,12 +171,12 @@ const poll = ({ check, interval = DEFAULT_INTERVAL, timeout, signal }) => new Pr
|
|
|
171
171
|
const defaultSettings = {
|
|
172
172
|
baseCDN: 'https://ucarecdn.com',
|
|
173
173
|
baseURL: 'https://upload.uploadcare.com',
|
|
174
|
-
maxContentLength: 50 * 1024 * 1024,
|
|
174
|
+
maxContentLength: 50 * 1024 * 1024, // 50 MB
|
|
175
175
|
retryThrottledRequestMaxTimes: 1,
|
|
176
176
|
retryNetworkErrorMaxTimes: 3,
|
|
177
|
-
multipartMinFileSize: 25 * 1024 * 1024,
|
|
178
|
-
multipartChunkSize: 5 * 1024 * 1024,
|
|
179
|
-
multipartMinLastPartSize: 1024 * 1024,
|
|
177
|
+
multipartMinFileSize: 25 * 1024 * 1024, // 25 MB
|
|
178
|
+
multipartChunkSize: 5 * 1024 * 1024, // 5 MB
|
|
179
|
+
multipartMinLastPartSize: 1024 * 1024, // 1MB
|
|
180
180
|
maxConcurrentRequests: 4,
|
|
181
181
|
pollingTimeoutMilliseconds: 10000,
|
|
182
182
|
pusherKey: '79ae88bd931ea68464d9'
|
|
@@ -405,7 +405,7 @@ const getUrl = (base, path, query) => {
|
|
|
405
405
|
return url.toString();
|
|
406
406
|
};
|
|
407
407
|
|
|
408
|
-
var version = '6.
|
|
408
|
+
var version = '6.14.0';
|
|
409
409
|
|
|
410
410
|
const LIBRARY_NAME = 'UploadcareUploadClient';
|
|
411
411
|
const LIBRARY_VERSION = version;
|
|
@@ -1306,7 +1306,9 @@ const sliceChunk = (file, index, fileSize, chunkSize) => {
|
|
|
1306
1306
|
};
|
|
1307
1307
|
|
|
1308
1308
|
const prepareChunks = async (file, fileSize, chunkSize) => {
|
|
1309
|
-
return
|
|
1309
|
+
return {
|
|
1310
|
+
getChunk: (index) => sliceChunk(file, index, fileSize, chunkSize)
|
|
1311
|
+
};
|
|
1310
1312
|
};
|
|
1311
1313
|
|
|
1312
1314
|
const uploadPart = (chunk, url, { publicKey, contentType, onProgress, signal, integration, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }) => multipartUpload(chunk, url, {
|
|
@@ -1357,10 +1359,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1357
1359
|
metadata
|
|
1358
1360
|
})
|
|
1359
1361
|
.then(async ({ uuid, parts }) => {
|
|
1360
|
-
const getChunk = await prepareChunks(file, size, multipartChunkSize);
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1362
|
+
const { getChunk, disposeChunks, disposeChunk } = await prepareChunks(file, size, multipartChunkSize);
|
|
1363
|
+
await runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => async () => {
|
|
1364
|
+
const chunk = getChunk(index);
|
|
1365
|
+
return uploadPart(chunk, url, {
|
|
1364
1366
|
publicKey,
|
|
1365
1367
|
contentType,
|
|
1366
1368
|
onProgress: createProgressHandler(parts.length, index),
|
|
@@ -1368,10 +1370,11 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1368
1370
|
integration,
|
|
1369
1371
|
retryThrottledRequestMaxTimes,
|
|
1370
1372
|
retryNetworkErrorMaxTimes
|
|
1371
|
-
})))
|
|
1372
|
-
|
|
1373
|
+
}).finally(() => disposeChunk?.(chunk));
|
|
1374
|
+
})).finally(() => disposeChunks?.());
|
|
1375
|
+
return uuid;
|
|
1373
1376
|
})
|
|
1374
|
-
.then((
|
|
1377
|
+
.then((uuid) => multipartComplete(uuid, {
|
|
1375
1378
|
publicKey,
|
|
1376
1379
|
baseURL,
|
|
1377
1380
|
source,
|
package/dist/cjs/index.node.cjs
CHANGED
|
@@ -178,12 +178,12 @@ const poll = ({ check, interval = DEFAULT_INTERVAL, timeout, signal }) => new Pr
|
|
|
178
178
|
const defaultSettings = {
|
|
179
179
|
baseCDN: 'https://ucarecdn.com',
|
|
180
180
|
baseURL: 'https://upload.uploadcare.com',
|
|
181
|
-
maxContentLength: 50 * 1024 * 1024,
|
|
181
|
+
maxContentLength: 50 * 1024 * 1024, // 50 MB
|
|
182
182
|
retryThrottledRequestMaxTimes: 1,
|
|
183
183
|
retryNetworkErrorMaxTimes: 3,
|
|
184
|
-
multipartMinFileSize: 25 * 1024 * 1024,
|
|
185
|
-
multipartChunkSize: 5 * 1024 * 1024,
|
|
186
|
-
multipartMinLastPartSize: 1024 * 1024,
|
|
184
|
+
multipartMinFileSize: 25 * 1024 * 1024, // 25 MB
|
|
185
|
+
multipartChunkSize: 5 * 1024 * 1024, // 5 MB
|
|
186
|
+
multipartMinLastPartSize: 1024 * 1024, // 1MB
|
|
187
187
|
maxConcurrentRequests: 4,
|
|
188
188
|
pollingTimeoutMilliseconds: 10000,
|
|
189
189
|
pusherKey: '79ae88bd931ea68464d9'
|
|
@@ -436,7 +436,7 @@ const getUrl = (base, path, query) => {
|
|
|
436
436
|
return url.toString();
|
|
437
437
|
};
|
|
438
438
|
|
|
439
|
-
var version = '6.
|
|
439
|
+
var version = '6.14.0';
|
|
440
440
|
|
|
441
441
|
const LIBRARY_NAME = 'UploadcareUploadClient';
|
|
442
442
|
const LIBRARY_VERSION = version;
|
|
@@ -1338,7 +1338,9 @@ const sliceChunk = (file, index, fileSize, chunkSize) => {
|
|
|
1338
1338
|
};
|
|
1339
1339
|
|
|
1340
1340
|
const prepareChunks = async (file, fileSize, chunkSize) => {
|
|
1341
|
-
return
|
|
1341
|
+
return {
|
|
1342
|
+
getChunk: (index) => sliceChunk(file, index, fileSize, chunkSize)
|
|
1343
|
+
};
|
|
1342
1344
|
};
|
|
1343
1345
|
|
|
1344
1346
|
const uploadPart = (chunk, url, { publicKey, contentType, onProgress, signal, integration, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }) => multipartUpload(chunk, url, {
|
|
@@ -1389,10 +1391,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1389
1391
|
metadata
|
|
1390
1392
|
})
|
|
1391
1393
|
.then(async ({ uuid, parts }) => {
|
|
1392
|
-
const getChunk = await prepareChunks(file, size, multipartChunkSize);
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1394
|
+
const { getChunk, disposeChunks, disposeChunk } = await prepareChunks(file, size, multipartChunkSize);
|
|
1395
|
+
await runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => async () => {
|
|
1396
|
+
const chunk = getChunk(index);
|
|
1397
|
+
return uploadPart(chunk, url, {
|
|
1396
1398
|
publicKey,
|
|
1397
1399
|
contentType,
|
|
1398
1400
|
onProgress: createProgressHandler(parts.length, index),
|
|
@@ -1400,10 +1402,11 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1400
1402
|
integration,
|
|
1401
1403
|
retryThrottledRequestMaxTimes,
|
|
1402
1404
|
retryNetworkErrorMaxTimes
|
|
1403
|
-
})))
|
|
1404
|
-
|
|
1405
|
+
}).finally(() => disposeChunk?.(chunk));
|
|
1406
|
+
})).finally(() => disposeChunks?.());
|
|
1407
|
+
return uuid;
|
|
1405
1408
|
})
|
|
1406
|
-
.then((
|
|
1409
|
+
.then((uuid) => multipartComplete(uuid, {
|
|
1407
1410
|
publicKey,
|
|
1408
1411
|
baseURL,
|
|
1409
1412
|
source,
|
|
@@ -171,12 +171,12 @@ const poll = ({ check, interval = DEFAULT_INTERVAL, timeout, signal }) => new Pr
|
|
|
171
171
|
const defaultSettings = {
|
|
172
172
|
baseCDN: 'https://ucarecdn.com',
|
|
173
173
|
baseURL: 'https://upload.uploadcare.com',
|
|
174
|
-
maxContentLength: 50 * 1024 * 1024,
|
|
174
|
+
maxContentLength: 50 * 1024 * 1024, // 50 MB
|
|
175
175
|
retryThrottledRequestMaxTimes: 1,
|
|
176
176
|
retryNetworkErrorMaxTimes: 3,
|
|
177
|
-
multipartMinFileSize: 25 * 1024 * 1024,
|
|
178
|
-
multipartChunkSize: 5 * 1024 * 1024,
|
|
179
|
-
multipartMinLastPartSize: 1024 * 1024,
|
|
177
|
+
multipartMinFileSize: 25 * 1024 * 1024, // 25 MB
|
|
178
|
+
multipartChunkSize: 5 * 1024 * 1024, // 5 MB
|
|
179
|
+
multipartMinLastPartSize: 1024 * 1024, // 1MB
|
|
180
180
|
maxConcurrentRequests: 4,
|
|
181
181
|
pollingTimeoutMilliseconds: 10000,
|
|
182
182
|
pusherKey: '79ae88bd931ea68464d9'
|
|
@@ -413,7 +413,7 @@ const getUrl = (base, path, query) => {
|
|
|
413
413
|
return url.toString();
|
|
414
414
|
};
|
|
415
415
|
|
|
416
|
-
var version = '6.
|
|
416
|
+
var version = '6.14.0';
|
|
417
417
|
|
|
418
418
|
const LIBRARY_NAME = 'UploadcareUploadClient';
|
|
419
419
|
const LIBRARY_VERSION = version;
|
|
@@ -1331,9 +1331,27 @@ const prepareChunks = async (file, fileSize, chunkSize) => {
|
|
|
1331
1331
|
else {
|
|
1332
1332
|
blob = file;
|
|
1333
1333
|
}
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1334
|
+
const chunks = new Set();
|
|
1335
|
+
return {
|
|
1336
|
+
getChunk: (index) => {
|
|
1337
|
+
const chunk = sliceChunk(blob, index, fileSize, chunkSize);
|
|
1338
|
+
chunks.add(chunk);
|
|
1339
|
+
return chunk;
|
|
1340
|
+
},
|
|
1341
|
+
/**
|
|
1342
|
+
* Remove references to all the chunks from the memory to make able
|
|
1343
|
+
* react-native to deallocate it
|
|
1344
|
+
*/
|
|
1345
|
+
disposeChunks: () => {
|
|
1346
|
+
chunks.clear();
|
|
1347
|
+
},
|
|
1348
|
+
/**
|
|
1349
|
+
* Remove specific chunk reference from the memory to make able react-native
|
|
1350
|
+
* to deallocate it
|
|
1351
|
+
*/
|
|
1352
|
+
disposeChunk: (chunk) => {
|
|
1353
|
+
chunks.delete(chunk);
|
|
1354
|
+
}
|
|
1337
1355
|
};
|
|
1338
1356
|
};
|
|
1339
1357
|
|
|
@@ -1385,10 +1403,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1385
1403
|
metadata
|
|
1386
1404
|
})
|
|
1387
1405
|
.then(async ({ uuid, parts }) => {
|
|
1388
|
-
const getChunk = await prepareChunks(file, size, multipartChunkSize);
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1406
|
+
const { getChunk, disposeChunks, disposeChunk } = await prepareChunks(file, size, multipartChunkSize);
|
|
1407
|
+
await runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => async () => {
|
|
1408
|
+
const chunk = getChunk(index);
|
|
1409
|
+
return uploadPart(chunk, url, {
|
|
1392
1410
|
publicKey,
|
|
1393
1411
|
contentType,
|
|
1394
1412
|
onProgress: createProgressHandler(parts.length, index),
|
|
@@ -1396,10 +1414,11 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1396
1414
|
integration,
|
|
1397
1415
|
retryThrottledRequestMaxTimes,
|
|
1398
1416
|
retryNetworkErrorMaxTimes
|
|
1399
|
-
})))
|
|
1400
|
-
|
|
1417
|
+
}).finally(() => disposeChunk?.(chunk));
|
|
1418
|
+
})).finally(() => disposeChunks?.());
|
|
1419
|
+
return uuid;
|
|
1401
1420
|
})
|
|
1402
|
-
.then((
|
|
1421
|
+
.then((uuid) => multipartComplete(uuid, {
|
|
1403
1422
|
publicKey,
|
|
1404
1423
|
baseURL,
|
|
1405
1424
|
source,
|
|
@@ -169,12 +169,12 @@ const poll = ({ check, interval = DEFAULT_INTERVAL, timeout, signal }) => new Pr
|
|
|
169
169
|
const defaultSettings = {
|
|
170
170
|
baseCDN: 'https://ucarecdn.com',
|
|
171
171
|
baseURL: 'https://upload.uploadcare.com',
|
|
172
|
-
maxContentLength: 50 * 1024 * 1024,
|
|
172
|
+
maxContentLength: 50 * 1024 * 1024, // 50 MB
|
|
173
173
|
retryThrottledRequestMaxTimes: 1,
|
|
174
174
|
retryNetworkErrorMaxTimes: 3,
|
|
175
|
-
multipartMinFileSize: 25 * 1024 * 1024,
|
|
176
|
-
multipartChunkSize: 5 * 1024 * 1024,
|
|
177
|
-
multipartMinLastPartSize: 1024 * 1024,
|
|
175
|
+
multipartMinFileSize: 25 * 1024 * 1024, // 25 MB
|
|
176
|
+
multipartChunkSize: 5 * 1024 * 1024, // 5 MB
|
|
177
|
+
multipartMinLastPartSize: 1024 * 1024, // 1MB
|
|
178
178
|
maxConcurrentRequests: 4,
|
|
179
179
|
pollingTimeoutMilliseconds: 10000,
|
|
180
180
|
pusherKey: '79ae88bd931ea68464d9'
|
|
@@ -403,7 +403,7 @@ const getUrl = (base, path, query) => {
|
|
|
403
403
|
return url.toString();
|
|
404
404
|
};
|
|
405
405
|
|
|
406
|
-
var version = '6.
|
|
406
|
+
var version = '6.14.0';
|
|
407
407
|
|
|
408
408
|
const LIBRARY_NAME = 'UploadcareUploadClient';
|
|
409
409
|
const LIBRARY_VERSION = version;
|
|
@@ -1304,7 +1304,9 @@ const sliceChunk = (file, index, fileSize, chunkSize) => {
|
|
|
1304
1304
|
};
|
|
1305
1305
|
|
|
1306
1306
|
const prepareChunks = async (file, fileSize, chunkSize) => {
|
|
1307
|
-
return
|
|
1307
|
+
return {
|
|
1308
|
+
getChunk: (index) => sliceChunk(file, index, fileSize, chunkSize)
|
|
1309
|
+
};
|
|
1308
1310
|
};
|
|
1309
1311
|
|
|
1310
1312
|
const uploadPart = (chunk, url, { publicKey, contentType, onProgress, signal, integration, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }) => multipartUpload(chunk, url, {
|
|
@@ -1355,10 +1357,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1355
1357
|
metadata
|
|
1356
1358
|
})
|
|
1357
1359
|
.then(async ({ uuid, parts }) => {
|
|
1358
|
-
const getChunk = await prepareChunks(file, size, multipartChunkSize);
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1360
|
+
const { getChunk, disposeChunks, disposeChunk } = await prepareChunks(file, size, multipartChunkSize);
|
|
1361
|
+
await runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => async () => {
|
|
1362
|
+
const chunk = getChunk(index);
|
|
1363
|
+
return uploadPart(chunk, url, {
|
|
1362
1364
|
publicKey,
|
|
1363
1365
|
contentType,
|
|
1364
1366
|
onProgress: createProgressHandler(parts.length, index),
|
|
@@ -1366,10 +1368,11 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1366
1368
|
integration,
|
|
1367
1369
|
retryThrottledRequestMaxTimes,
|
|
1368
1370
|
retryNetworkErrorMaxTimes
|
|
1369
|
-
})))
|
|
1370
|
-
|
|
1371
|
+
}).finally(() => disposeChunk?.(chunk));
|
|
1372
|
+
})).finally(() => disposeChunks?.());
|
|
1373
|
+
return uuid;
|
|
1371
1374
|
})
|
|
1372
|
-
.then((
|
|
1375
|
+
.then((uuid) => multipartComplete(uuid, {
|
|
1373
1376
|
publicKey,
|
|
1374
1377
|
baseURL,
|
|
1375
1378
|
source,
|
package/dist/esm/index.node.mjs
CHANGED
|
@@ -176,12 +176,12 @@ const poll = ({ check, interval = DEFAULT_INTERVAL, timeout, signal }) => new Pr
|
|
|
176
176
|
const defaultSettings = {
|
|
177
177
|
baseCDN: 'https://ucarecdn.com',
|
|
178
178
|
baseURL: 'https://upload.uploadcare.com',
|
|
179
|
-
maxContentLength: 50 * 1024 * 1024,
|
|
179
|
+
maxContentLength: 50 * 1024 * 1024, // 50 MB
|
|
180
180
|
retryThrottledRequestMaxTimes: 1,
|
|
181
181
|
retryNetworkErrorMaxTimes: 3,
|
|
182
|
-
multipartMinFileSize: 25 * 1024 * 1024,
|
|
183
|
-
multipartChunkSize: 5 * 1024 * 1024,
|
|
184
|
-
multipartMinLastPartSize: 1024 * 1024,
|
|
182
|
+
multipartMinFileSize: 25 * 1024 * 1024, // 25 MB
|
|
183
|
+
multipartChunkSize: 5 * 1024 * 1024, // 5 MB
|
|
184
|
+
multipartMinLastPartSize: 1024 * 1024, // 1MB
|
|
185
185
|
maxConcurrentRequests: 4,
|
|
186
186
|
pollingTimeoutMilliseconds: 10000,
|
|
187
187
|
pusherKey: '79ae88bd931ea68464d9'
|
|
@@ -434,7 +434,7 @@ const getUrl = (base, path, query) => {
|
|
|
434
434
|
return url.toString();
|
|
435
435
|
};
|
|
436
436
|
|
|
437
|
-
var version = '6.
|
|
437
|
+
var version = '6.14.0';
|
|
438
438
|
|
|
439
439
|
const LIBRARY_NAME = 'UploadcareUploadClient';
|
|
440
440
|
const LIBRARY_VERSION = version;
|
|
@@ -1336,7 +1336,9 @@ const sliceChunk = (file, index, fileSize, chunkSize) => {
|
|
|
1336
1336
|
};
|
|
1337
1337
|
|
|
1338
1338
|
const prepareChunks = async (file, fileSize, chunkSize) => {
|
|
1339
|
-
return
|
|
1339
|
+
return {
|
|
1340
|
+
getChunk: (index) => sliceChunk(file, index, fileSize, chunkSize)
|
|
1341
|
+
};
|
|
1340
1342
|
};
|
|
1341
1343
|
|
|
1342
1344
|
const uploadPart = (chunk, url, { publicKey, contentType, onProgress, signal, integration, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }) => multipartUpload(chunk, url, {
|
|
@@ -1387,10 +1389,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1387
1389
|
metadata
|
|
1388
1390
|
})
|
|
1389
1391
|
.then(async ({ uuid, parts }) => {
|
|
1390
|
-
const getChunk = await prepareChunks(file, size, multipartChunkSize);
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1392
|
+
const { getChunk, disposeChunks, disposeChunk } = await prepareChunks(file, size, multipartChunkSize);
|
|
1393
|
+
await runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => async () => {
|
|
1394
|
+
const chunk = getChunk(index);
|
|
1395
|
+
return uploadPart(chunk, url, {
|
|
1394
1396
|
publicKey,
|
|
1395
1397
|
contentType,
|
|
1396
1398
|
onProgress: createProgressHandler(parts.length, index),
|
|
@@ -1398,10 +1400,11 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1398
1400
|
integration,
|
|
1399
1401
|
retryThrottledRequestMaxTimes,
|
|
1400
1402
|
retryNetworkErrorMaxTimes
|
|
1401
|
-
})))
|
|
1402
|
-
|
|
1403
|
+
}).finally(() => disposeChunk?.(chunk));
|
|
1404
|
+
})).finally(() => disposeChunks?.());
|
|
1405
|
+
return uuid;
|
|
1403
1406
|
})
|
|
1404
|
-
.then((
|
|
1407
|
+
.then((uuid) => multipartComplete(uuid, {
|
|
1405
1408
|
publicKey,
|
|
1406
1409
|
baseURL,
|
|
1407
1410
|
source,
|
|
@@ -169,12 +169,12 @@ const poll = ({ check, interval = DEFAULT_INTERVAL, timeout, signal }) => new Pr
|
|
|
169
169
|
const defaultSettings = {
|
|
170
170
|
baseCDN: 'https://ucarecdn.com',
|
|
171
171
|
baseURL: 'https://upload.uploadcare.com',
|
|
172
|
-
maxContentLength: 50 * 1024 * 1024,
|
|
172
|
+
maxContentLength: 50 * 1024 * 1024, // 50 MB
|
|
173
173
|
retryThrottledRequestMaxTimes: 1,
|
|
174
174
|
retryNetworkErrorMaxTimes: 3,
|
|
175
|
-
multipartMinFileSize: 25 * 1024 * 1024,
|
|
176
|
-
multipartChunkSize: 5 * 1024 * 1024,
|
|
177
|
-
multipartMinLastPartSize: 1024 * 1024,
|
|
175
|
+
multipartMinFileSize: 25 * 1024 * 1024, // 25 MB
|
|
176
|
+
multipartChunkSize: 5 * 1024 * 1024, // 5 MB
|
|
177
|
+
multipartMinLastPartSize: 1024 * 1024, // 1MB
|
|
178
178
|
maxConcurrentRequests: 4,
|
|
179
179
|
pollingTimeoutMilliseconds: 10000,
|
|
180
180
|
pusherKey: '79ae88bd931ea68464d9'
|
|
@@ -411,7 +411,7 @@ const getUrl = (base, path, query) => {
|
|
|
411
411
|
return url.toString();
|
|
412
412
|
};
|
|
413
413
|
|
|
414
|
-
var version = '6.
|
|
414
|
+
var version = '6.14.0';
|
|
415
415
|
|
|
416
416
|
const LIBRARY_NAME = 'UploadcareUploadClient';
|
|
417
417
|
const LIBRARY_VERSION = version;
|
|
@@ -1329,9 +1329,27 @@ const prepareChunks = async (file, fileSize, chunkSize) => {
|
|
|
1329
1329
|
else {
|
|
1330
1330
|
blob = file;
|
|
1331
1331
|
}
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1332
|
+
const chunks = new Set();
|
|
1333
|
+
return {
|
|
1334
|
+
getChunk: (index) => {
|
|
1335
|
+
const chunk = sliceChunk(blob, index, fileSize, chunkSize);
|
|
1336
|
+
chunks.add(chunk);
|
|
1337
|
+
return chunk;
|
|
1338
|
+
},
|
|
1339
|
+
/**
|
|
1340
|
+
* Remove references to all the chunks from the memory to make able
|
|
1341
|
+
* react-native to deallocate it
|
|
1342
|
+
*/
|
|
1343
|
+
disposeChunks: () => {
|
|
1344
|
+
chunks.clear();
|
|
1345
|
+
},
|
|
1346
|
+
/**
|
|
1347
|
+
* Remove specific chunk reference from the memory to make able react-native
|
|
1348
|
+
* to deallocate it
|
|
1349
|
+
*/
|
|
1350
|
+
disposeChunk: (chunk) => {
|
|
1351
|
+
chunks.delete(chunk);
|
|
1352
|
+
}
|
|
1335
1353
|
};
|
|
1336
1354
|
};
|
|
1337
1355
|
|
|
@@ -1383,10 +1401,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1383
1401
|
metadata
|
|
1384
1402
|
})
|
|
1385
1403
|
.then(async ({ uuid, parts }) => {
|
|
1386
|
-
const getChunk = await prepareChunks(file, size, multipartChunkSize);
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1404
|
+
const { getChunk, disposeChunks, disposeChunk } = await prepareChunks(file, size, multipartChunkSize);
|
|
1405
|
+
await runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => async () => {
|
|
1406
|
+
const chunk = getChunk(index);
|
|
1407
|
+
return uploadPart(chunk, url, {
|
|
1390
1408
|
publicKey,
|
|
1391
1409
|
contentType,
|
|
1392
1410
|
onProgress: createProgressHandler(parts.length, index),
|
|
@@ -1394,10 +1412,11 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1394
1412
|
integration,
|
|
1395
1413
|
retryThrottledRequestMaxTimes,
|
|
1396
1414
|
retryNetworkErrorMaxTimes
|
|
1397
|
-
})))
|
|
1398
|
-
|
|
1415
|
+
}).finally(() => disposeChunk?.(chunk));
|
|
1416
|
+
})).finally(() => disposeChunks?.());
|
|
1417
|
+
return uuid;
|
|
1399
1418
|
})
|
|
1400
|
-
.then((
|
|
1419
|
+
.then((uuid) => multipartComplete(uuid, {
|
|
1401
1420
|
publicKey,
|
|
1402
1421
|
baseURL,
|
|
1403
1422
|
source,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uploadcare/upload-client",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.14.1-alpha.0",
|
|
4
4
|
"description": "Library for work with Uploadcare Upload API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/esm/index.node.mjs",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"koa-body": "5.0.0",
|
|
91
91
|
"mock-socket": "9.0.3",
|
|
92
92
|
"start-server-and-test": "1.14.0",
|
|
93
|
-
"@uploadcare/api-client-utils": "^6.
|
|
93
|
+
"@uploadcare/api-client-utils": "^6.14.0",
|
|
94
94
|
"chalk": "^4.1.2"
|
|
95
95
|
},
|
|
96
96
|
"dependencies": {
|