@uploadcare/upload-client 6.1.0 → 6.2.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/README.md +0 -7
- package/dist/index.browser.js +15 -6
- package/dist/index.d.ts +10 -8
- package/dist/index.node.js +15 -6
- package/dist/index.react-native.js +15 -6
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/index.browser.js
CHANGED
|
@@ -390,7 +390,7 @@ const getUrl = (base, path, query) => {
|
|
|
390
390
|
return url.toString();
|
|
391
391
|
};
|
|
392
392
|
|
|
393
|
-
var version = '6.
|
|
393
|
+
var version = '6.2.0';
|
|
394
394
|
|
|
395
395
|
const LIBRARY_NAME = 'UploadcareUploadClient';
|
|
396
396
|
const LIBRARY_VERSION = version;
|
|
@@ -455,7 +455,10 @@ const getFileName = (file) => {
|
|
|
455
455
|
};
|
|
456
456
|
|
|
457
457
|
function getStoreValue(store) {
|
|
458
|
-
|
|
458
|
+
if (typeof store === 'undefined' || store === 'auto') {
|
|
459
|
+
return 'auto';
|
|
460
|
+
}
|
|
461
|
+
return store ? '1' : '0';
|
|
459
462
|
}
|
|
460
463
|
|
|
461
464
|
/**
|
|
@@ -701,14 +704,17 @@ function multipartStart(size, { publicKey, contentType, fileName, multipartChunk
|
|
|
701
704
|
/**
|
|
702
705
|
* Complete multipart uploading.
|
|
703
706
|
*/
|
|
704
|
-
function multipartUpload(part, url, { signal, onProgress, retryThrottledRequestMaxTimes = defaultSettings.retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes = defaultSettings.retryNetworkErrorMaxTimes }) {
|
|
707
|
+
function multipartUpload(part, url, { contentType, signal, onProgress, retryThrottledRequestMaxTimes = defaultSettings.retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes = defaultSettings.retryNetworkErrorMaxTimes }) {
|
|
705
708
|
return retryIfFailed(() => request({
|
|
706
709
|
method: 'PUT',
|
|
707
710
|
url,
|
|
708
711
|
data: part,
|
|
709
712
|
// Upload request can't be non-computable because we always know exact size
|
|
710
713
|
onProgress: onProgress,
|
|
711
|
-
signal
|
|
714
|
+
signal,
|
|
715
|
+
headers: {
|
|
716
|
+
'Content-Type': contentType || defaultContentType
|
|
717
|
+
}
|
|
712
718
|
})
|
|
713
719
|
.then((result) => {
|
|
714
720
|
// hack for node ¯\_(ツ)_/¯
|
|
@@ -1303,8 +1309,9 @@ const prepareChunks = async (file, fileSize, chunkSize) => {
|
|
|
1303
1309
|
return (index) => sliceChunk(file, index, fileSize, chunkSize);
|
|
1304
1310
|
};
|
|
1305
1311
|
|
|
1306
|
-
const uploadPart = (chunk, url, { publicKey, onProgress, signal, integration, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }) => multipartUpload(chunk, url, {
|
|
1312
|
+
const uploadPart = (chunk, url, { publicKey, contentType, onProgress, signal, integration, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }) => multipartUpload(chunk, url, {
|
|
1307
1313
|
publicKey,
|
|
1314
|
+
contentType,
|
|
1308
1315
|
onProgress,
|
|
1309
1316
|
signal,
|
|
1310
1317
|
integration,
|
|
@@ -1332,9 +1339,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1332
1339
|
});
|
|
1333
1340
|
};
|
|
1334
1341
|
};
|
|
1342
|
+
contentType || (contentType = getContentType(file));
|
|
1335
1343
|
return multipartStart(size, {
|
|
1336
1344
|
publicKey,
|
|
1337
|
-
contentType
|
|
1345
|
+
contentType,
|
|
1338
1346
|
fileName: fileName || getFileName(file),
|
|
1339
1347
|
baseURL,
|
|
1340
1348
|
secureSignature,
|
|
@@ -1354,6 +1362,7 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1354
1362
|
uuid,
|
|
1355
1363
|
runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => () => uploadPart(getChunk(index), url, {
|
|
1356
1364
|
publicKey,
|
|
1365
|
+
contentType,
|
|
1357
1366
|
onProgress: createProgressHandler(parts.length, index),
|
|
1358
1367
|
signal,
|
|
1359
1368
|
integration,
|
package/dist/index.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ export declare type ContentInfo = {
|
|
|
71
71
|
video?: VideoInfo;
|
|
72
72
|
};
|
|
73
73
|
export declare type Metadata = Record<string, string>;
|
|
74
|
+
export declare type StoreValue = "auto" | boolean;
|
|
74
75
|
export interface DefaultSettings {
|
|
75
76
|
baseCDN: string;
|
|
76
77
|
baseURL: string;
|
|
@@ -88,7 +89,7 @@ export interface Settings extends Partial<DefaultSettings> {
|
|
|
88
89
|
publicKey: string;
|
|
89
90
|
fileName?: string;
|
|
90
91
|
contentType?: string;
|
|
91
|
-
store?:
|
|
92
|
+
store?: StoreValue;
|
|
92
93
|
secureSignature?: string;
|
|
93
94
|
secureExpire?: string;
|
|
94
95
|
integration?: string;
|
|
@@ -155,7 +156,7 @@ export declare type BaseOptions = {
|
|
|
155
156
|
baseURL?: string;
|
|
156
157
|
secureSignature?: string;
|
|
157
158
|
secureExpire?: string;
|
|
158
|
-
store?:
|
|
159
|
+
store?: StoreValue;
|
|
159
160
|
contentType?: string;
|
|
160
161
|
signal?: AbortSignal;
|
|
161
162
|
onProgress?: ProgressCallback;
|
|
@@ -187,7 +188,7 @@ export declare type FromUrlResponse = FromUrlSuccessResponse;
|
|
|
187
188
|
export declare type FromUrlOptions = {
|
|
188
189
|
publicKey: string;
|
|
189
190
|
baseURL?: string;
|
|
190
|
-
store?:
|
|
191
|
+
store?: StoreValue;
|
|
191
192
|
fileName?: string;
|
|
192
193
|
checkForUrlDuplicates?: boolean;
|
|
193
194
|
saveUrlForRecurrentUploads?: boolean;
|
|
@@ -298,7 +299,7 @@ export declare type MultipartStartOptions = {
|
|
|
298
299
|
baseURL?: string;
|
|
299
300
|
secureSignature?: string;
|
|
300
301
|
secureExpire?: string;
|
|
301
|
-
store?:
|
|
302
|
+
store?: StoreValue;
|
|
302
303
|
multipartChunkSize?: number;
|
|
303
304
|
signal?: AbortSignal;
|
|
304
305
|
source?: string;
|
|
@@ -319,6 +320,7 @@ export declare type MultipartStartResponse = {
|
|
|
319
320
|
export function multipartStart(size: number, { publicKey, contentType, fileName, multipartChunkSize, baseURL, secureSignature, secureExpire, store, signal, source, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes, metadata }: MultipartStartOptions): Promise<MultipartStartResponse>;
|
|
320
321
|
export declare type MultipartUploadOptions = {
|
|
321
322
|
publicKey?: string;
|
|
323
|
+
contentType?: string;
|
|
322
324
|
signal?: AbortSignal;
|
|
323
325
|
onProgress?: ProgressCallback<ComputableProgressInfo>;
|
|
324
326
|
integration?: string;
|
|
@@ -331,7 +333,7 @@ export declare type MultipartUploadResponse = {
|
|
|
331
333
|
/**
|
|
332
334
|
* Complete multipart uploading.
|
|
333
335
|
*/
|
|
334
|
-
export function multipartUpload(part: SupportedFileInput, url: MultipartPart, { signal, onProgress, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }: MultipartUploadOptions): Promise<MultipartUploadResponse>;
|
|
336
|
+
export function multipartUpload(part: SupportedFileInput, url: MultipartPart, { contentType, signal, onProgress, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }: MultipartUploadOptions): Promise<MultipartUploadResponse>;
|
|
335
337
|
export declare type MultipartCompleteOptions = {
|
|
336
338
|
publicKey: string;
|
|
337
339
|
baseURL?: string;
|
|
@@ -372,7 +374,7 @@ export declare type FileFromOptions = {
|
|
|
372
374
|
baseURL?: string;
|
|
373
375
|
secureSignature?: string;
|
|
374
376
|
secureExpire?: string;
|
|
375
|
-
store?:
|
|
377
|
+
store?: StoreValue;
|
|
376
378
|
signal?: AbortSignal;
|
|
377
379
|
onProgress?: ProgressCallback;
|
|
378
380
|
source?: string;
|
|
@@ -400,7 +402,7 @@ export declare type DirectOptions = {
|
|
|
400
402
|
baseURL?: string;
|
|
401
403
|
secureSignature?: string;
|
|
402
404
|
secureExpire?: string;
|
|
403
|
-
store?:
|
|
405
|
+
store?: StoreValue;
|
|
404
406
|
contentType?: string;
|
|
405
407
|
signal?: AbortSignal;
|
|
406
408
|
onProgress?: ProgressCallback;
|
|
@@ -442,7 +444,7 @@ export declare type MultipartOptions = {
|
|
|
442
444
|
baseURL?: string;
|
|
443
445
|
secureSignature?: string;
|
|
444
446
|
secureExpire?: string;
|
|
445
|
-
store?:
|
|
447
|
+
store?: StoreValue;
|
|
446
448
|
signal?: AbortSignal;
|
|
447
449
|
onProgress?: ProgressCallback<ComputableProgressInfo>;
|
|
448
450
|
source?: string;
|
package/dist/index.node.js
CHANGED
|
@@ -418,7 +418,7 @@ const getUrl = (base, path, query) => {
|
|
|
418
418
|
return url.toString();
|
|
419
419
|
};
|
|
420
420
|
|
|
421
|
-
var version = '6.
|
|
421
|
+
var version = '6.2.0';
|
|
422
422
|
|
|
423
423
|
const LIBRARY_NAME = 'UploadcareUploadClient';
|
|
424
424
|
const LIBRARY_VERSION = version;
|
|
@@ -483,7 +483,10 @@ const getFileName = (file) => {
|
|
|
483
483
|
};
|
|
484
484
|
|
|
485
485
|
function getStoreValue(store) {
|
|
486
|
-
|
|
486
|
+
if (typeof store === 'undefined' || store === 'auto') {
|
|
487
|
+
return 'auto';
|
|
488
|
+
}
|
|
489
|
+
return store ? '1' : '0';
|
|
487
490
|
}
|
|
488
491
|
|
|
489
492
|
/**
|
|
@@ -729,14 +732,17 @@ function multipartStart(size, { publicKey, contentType, fileName, multipartChunk
|
|
|
729
732
|
/**
|
|
730
733
|
* Complete multipart uploading.
|
|
731
734
|
*/
|
|
732
|
-
function multipartUpload(part, url, { signal, onProgress, retryThrottledRequestMaxTimes = defaultSettings.retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes = defaultSettings.retryNetworkErrorMaxTimes }) {
|
|
735
|
+
function multipartUpload(part, url, { contentType, signal, onProgress, retryThrottledRequestMaxTimes = defaultSettings.retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes = defaultSettings.retryNetworkErrorMaxTimes }) {
|
|
733
736
|
return retryIfFailed(() => request({
|
|
734
737
|
method: 'PUT',
|
|
735
738
|
url,
|
|
736
739
|
data: part,
|
|
737
740
|
// Upload request can't be non-computable because we always know exact size
|
|
738
741
|
onProgress: onProgress,
|
|
739
|
-
signal
|
|
742
|
+
signal,
|
|
743
|
+
headers: {
|
|
744
|
+
'Content-Type': contentType || defaultContentType
|
|
745
|
+
}
|
|
740
746
|
})
|
|
741
747
|
.then((result) => {
|
|
742
748
|
// hack for node ¯\_(ツ)_/¯
|
|
@@ -1329,8 +1335,9 @@ const prepareChunks = async (file, fileSize, chunkSize) => {
|
|
|
1329
1335
|
return (index) => sliceChunk(file, index, fileSize, chunkSize);
|
|
1330
1336
|
};
|
|
1331
1337
|
|
|
1332
|
-
const uploadPart = (chunk, url, { publicKey, onProgress, signal, integration, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }) => multipartUpload(chunk, url, {
|
|
1338
|
+
const uploadPart = (chunk, url, { publicKey, contentType, onProgress, signal, integration, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }) => multipartUpload(chunk, url, {
|
|
1333
1339
|
publicKey,
|
|
1340
|
+
contentType,
|
|
1334
1341
|
onProgress,
|
|
1335
1342
|
signal,
|
|
1336
1343
|
integration,
|
|
@@ -1358,9 +1365,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1358
1365
|
});
|
|
1359
1366
|
};
|
|
1360
1367
|
};
|
|
1368
|
+
contentType || (contentType = getContentType(file));
|
|
1361
1369
|
return multipartStart(size, {
|
|
1362
1370
|
publicKey,
|
|
1363
|
-
contentType
|
|
1371
|
+
contentType,
|
|
1364
1372
|
fileName: fileName || getFileName(file),
|
|
1365
1373
|
baseURL,
|
|
1366
1374
|
secureSignature,
|
|
@@ -1380,6 +1388,7 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1380
1388
|
uuid,
|
|
1381
1389
|
runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => () => uploadPart(getChunk(index), url, {
|
|
1382
1390
|
publicKey,
|
|
1391
|
+
contentType,
|
|
1383
1392
|
onProgress: createProgressHandler(parts.length, index),
|
|
1384
1393
|
signal,
|
|
1385
1394
|
integration,
|
|
@@ -398,7 +398,7 @@ const getUrl = (base, path, query) => {
|
|
|
398
398
|
return url.toString();
|
|
399
399
|
};
|
|
400
400
|
|
|
401
|
-
var version = '6.
|
|
401
|
+
var version = '6.2.0';
|
|
402
402
|
|
|
403
403
|
const LIBRARY_NAME = 'UploadcareUploadClient';
|
|
404
404
|
const LIBRARY_VERSION = version;
|
|
@@ -463,7 +463,10 @@ const getFileName = (file) => {
|
|
|
463
463
|
};
|
|
464
464
|
|
|
465
465
|
function getStoreValue(store) {
|
|
466
|
-
|
|
466
|
+
if (typeof store === 'undefined' || store === 'auto') {
|
|
467
|
+
return 'auto';
|
|
468
|
+
}
|
|
469
|
+
return store ? '1' : '0';
|
|
467
470
|
}
|
|
468
471
|
|
|
469
472
|
/**
|
|
@@ -709,14 +712,17 @@ function multipartStart(size, { publicKey, contentType, fileName, multipartChunk
|
|
|
709
712
|
/**
|
|
710
713
|
* Complete multipart uploading.
|
|
711
714
|
*/
|
|
712
|
-
function multipartUpload(part, url, { signal, onProgress, retryThrottledRequestMaxTimes = defaultSettings.retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes = defaultSettings.retryNetworkErrorMaxTimes }) {
|
|
715
|
+
function multipartUpload(part, url, { contentType, signal, onProgress, retryThrottledRequestMaxTimes = defaultSettings.retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes = defaultSettings.retryNetworkErrorMaxTimes }) {
|
|
713
716
|
return retryIfFailed(() => request({
|
|
714
717
|
method: 'PUT',
|
|
715
718
|
url,
|
|
716
719
|
data: part,
|
|
717
720
|
// Upload request can't be non-computable because we always know exact size
|
|
718
721
|
onProgress: onProgress,
|
|
719
|
-
signal
|
|
722
|
+
signal,
|
|
723
|
+
headers: {
|
|
724
|
+
'Content-Type': contentType || defaultContentType
|
|
725
|
+
}
|
|
720
726
|
})
|
|
721
727
|
.then((result) => {
|
|
722
728
|
// hack for node ¯\_(ツ)_/¯
|
|
@@ -1331,8 +1337,9 @@ const prepareChunks = async (file, fileSize, chunkSize) => {
|
|
|
1331
1337
|
};
|
|
1332
1338
|
};
|
|
1333
1339
|
|
|
1334
|
-
const uploadPart = (chunk, url, { publicKey, onProgress, signal, integration, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }) => multipartUpload(chunk, url, {
|
|
1340
|
+
const uploadPart = (chunk, url, { publicKey, contentType, onProgress, signal, integration, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }) => multipartUpload(chunk, url, {
|
|
1335
1341
|
publicKey,
|
|
1342
|
+
contentType,
|
|
1336
1343
|
onProgress,
|
|
1337
1344
|
signal,
|
|
1338
1345
|
integration,
|
|
@@ -1360,9 +1367,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1360
1367
|
});
|
|
1361
1368
|
};
|
|
1362
1369
|
};
|
|
1370
|
+
contentType || (contentType = getContentType(file));
|
|
1363
1371
|
return multipartStart(size, {
|
|
1364
1372
|
publicKey,
|
|
1365
|
-
contentType
|
|
1373
|
+
contentType,
|
|
1366
1374
|
fileName: fileName || getFileName(file),
|
|
1367
1375
|
baseURL,
|
|
1368
1376
|
secureSignature,
|
|
@@ -1382,6 +1390,7 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1382
1390
|
uuid,
|
|
1383
1391
|
runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => () => uploadPart(getChunk(index), url, {
|
|
1384
1392
|
publicKey,
|
|
1393
|
+
contentType,
|
|
1385
1394
|
onProgress: createProgressHandler(parts.length, index),
|
|
1386
1395
|
signal,
|
|
1387
1396
|
integration,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uploadcare/upload-client",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Library for work with Uploadcare Upload API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/index.node.js",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"koa-body": "5.0.0",
|
|
79
79
|
"mock-socket": "9.0.3",
|
|
80
80
|
"start-server-and-test": "1.14.0",
|
|
81
|
-
"@uploadcare/api-client-utils": "^6.
|
|
81
|
+
"@uploadcare/api-client-utils": "^6.2.0",
|
|
82
82
|
"chalk": "^4.1.2"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|