@uploadcare/upload-client 6.0.1-alpha.6 → 6.0.1-alpha.8
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/index.browser.js +15 -11
- package/dist/index.node.js +15 -11
- package/dist/index.react-native.js +22 -15
- package/package.json +1 -1
package/dist/index.browser.js
CHANGED
|
@@ -262,11 +262,15 @@ const transformFile = identity;
|
|
|
262
262
|
var getFormData = () => new FormData();
|
|
263
263
|
|
|
264
264
|
const isReactNativeUri = (uri) => {
|
|
265
|
+
if (typeof uri !== 'string') {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
265
268
|
return uri.startsWith('file:') || uri.startsWith('content:');
|
|
266
269
|
};
|
|
267
270
|
const isReactNativeAsset = (asset) => {
|
|
268
|
-
return (
|
|
269
|
-
|
|
271
|
+
return (!!asset &&
|
|
272
|
+
typeof asset === 'object' &&
|
|
273
|
+
!Array.isArray(asset) &&
|
|
270
274
|
'uri' in asset &&
|
|
271
275
|
typeof asset.uri === 'string' &&
|
|
272
276
|
isReactNativeUri(asset.uri));
|
|
@@ -458,6 +462,10 @@ function retryIfFailed(fn, options) {
|
|
|
458
462
|
}));
|
|
459
463
|
}
|
|
460
464
|
|
|
465
|
+
function getStoreValue(store) {
|
|
466
|
+
return typeof store === 'undefined' ? 'auto' : store ? '1' : '0';
|
|
467
|
+
}
|
|
468
|
+
|
|
461
469
|
/**
|
|
462
470
|
* Performs file uploading request to Uploadcare Upload API.
|
|
463
471
|
* Can be canceled and has progress.
|
|
@@ -475,13 +483,13 @@ function base(file, { publicKey, fileName, contentType, baseURL = defaultSetting
|
|
|
475
483
|
file: {
|
|
476
484
|
data: file,
|
|
477
485
|
name: fileName ?? file?.name ?? defaultFilename,
|
|
478
|
-
contentType
|
|
486
|
+
contentType: contentType ?? file?.type ?? defaultContentType
|
|
479
487
|
},
|
|
480
488
|
UPLOADCARE_PUB_KEY: publicKey,
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
489
|
+
UPLOADCARE_STORE: getStoreValue(store),
|
|
490
|
+
signature: secureSignature,
|
|
491
|
+
expire: secureExpire,
|
|
492
|
+
source: source,
|
|
485
493
|
metadata
|
|
486
494
|
}),
|
|
487
495
|
signal,
|
|
@@ -497,10 +505,6 @@ function base(file, { publicKey, fileName, contentType, baseURL = defaultSetting
|
|
|
497
505
|
}), { retryNetworkErrorMaxTimes, retryThrottledRequestMaxTimes });
|
|
498
506
|
}
|
|
499
507
|
|
|
500
|
-
function getStoreValue(store) {
|
|
501
|
-
return typeof store === 'undefined' ? 'auto' : store ? '1' : '0';
|
|
502
|
-
}
|
|
503
|
-
|
|
504
508
|
var TypeEnum;
|
|
505
509
|
(function (TypeEnum) {
|
|
506
510
|
TypeEnum["Token"] = "token";
|
package/dist/index.node.js
CHANGED
|
@@ -286,11 +286,15 @@ const transformFile = identity;
|
|
|
286
286
|
var getFormData = () => new NodeFormData();
|
|
287
287
|
|
|
288
288
|
const isReactNativeUri = (uri) => {
|
|
289
|
+
if (typeof uri !== 'string') {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
289
292
|
return uri.startsWith('file:') || uri.startsWith('content:');
|
|
290
293
|
};
|
|
291
294
|
const isReactNativeAsset = (asset) => {
|
|
292
|
-
return (
|
|
293
|
-
|
|
295
|
+
return (!!asset &&
|
|
296
|
+
typeof asset === 'object' &&
|
|
297
|
+
!Array.isArray(asset) &&
|
|
294
298
|
'uri' in asset &&
|
|
295
299
|
typeof asset.uri === 'string' &&
|
|
296
300
|
isReactNativeUri(asset.uri));
|
|
@@ -482,6 +486,10 @@ function retryIfFailed(fn, options) {
|
|
|
482
486
|
}));
|
|
483
487
|
}
|
|
484
488
|
|
|
489
|
+
function getStoreValue(store) {
|
|
490
|
+
return typeof store === 'undefined' ? 'auto' : store ? '1' : '0';
|
|
491
|
+
}
|
|
492
|
+
|
|
485
493
|
/**
|
|
486
494
|
* Performs file uploading request to Uploadcare Upload API.
|
|
487
495
|
* Can be canceled and has progress.
|
|
@@ -499,13 +507,13 @@ function base(file, { publicKey, fileName, contentType, baseURL = defaultSetting
|
|
|
499
507
|
file: {
|
|
500
508
|
data: file,
|
|
501
509
|
name: fileName ?? file?.name ?? defaultFilename,
|
|
502
|
-
contentType
|
|
510
|
+
contentType: contentType ?? file?.type ?? defaultContentType
|
|
503
511
|
},
|
|
504
512
|
UPLOADCARE_PUB_KEY: publicKey,
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
513
|
+
UPLOADCARE_STORE: getStoreValue(store),
|
|
514
|
+
signature: secureSignature,
|
|
515
|
+
expire: secureExpire,
|
|
516
|
+
source: source,
|
|
509
517
|
metadata
|
|
510
518
|
}),
|
|
511
519
|
signal,
|
|
@@ -521,10 +529,6 @@ function base(file, { publicKey, fileName, contentType, baseURL = defaultSetting
|
|
|
521
529
|
}), { retryNetworkErrorMaxTimes, retryThrottledRequestMaxTimes });
|
|
522
530
|
}
|
|
523
531
|
|
|
524
|
-
function getStoreValue(store) {
|
|
525
|
-
return typeof store === 'undefined' ? 'auto' : store ? '1' : '0';
|
|
526
|
-
}
|
|
527
|
-
|
|
528
532
|
var TypeEnum;
|
|
529
533
|
(function (TypeEnum) {
|
|
530
534
|
TypeEnum["Token"] = "token";
|
|
@@ -254,11 +254,15 @@ const request = ({ method, url, data, headers = {}, signal, onProgress }) => new
|
|
|
254
254
|
});
|
|
255
255
|
|
|
256
256
|
const isReactNativeUri = (uri) => {
|
|
257
|
+
if (typeof uri !== 'string') {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
257
260
|
return uri.startsWith('file:') || uri.startsWith('content:');
|
|
258
261
|
};
|
|
259
262
|
const isReactNativeAsset = (asset) => {
|
|
260
|
-
return (
|
|
261
|
-
|
|
263
|
+
return (!!asset &&
|
|
264
|
+
typeof asset === 'object' &&
|
|
265
|
+
!Array.isArray(asset) &&
|
|
262
266
|
'uri' in asset &&
|
|
263
267
|
typeof asset.uri === 'string' &&
|
|
264
268
|
isReactNativeUri(asset.uri));
|
|
@@ -266,15 +270,18 @@ const isReactNativeAsset = (asset) => {
|
|
|
266
270
|
|
|
267
271
|
const getFileOptions = ({ name }) => name ? [name] : [];
|
|
268
272
|
const transformFile = (file, name, contentType) => {
|
|
269
|
-
if (
|
|
273
|
+
if (isReactNativeUri(file)) {
|
|
270
274
|
return { uri: file, name, type: contentType };
|
|
271
275
|
}
|
|
272
276
|
if (isReactNativeAsset(file)) {
|
|
273
|
-
return
|
|
277
|
+
return {
|
|
278
|
+
uri: file.uri,
|
|
279
|
+
name: file.name || name,
|
|
280
|
+
type: file.type || contentType
|
|
281
|
+
};
|
|
274
282
|
}
|
|
275
283
|
const uri = URL.createObjectURL(file);
|
|
276
|
-
|
|
277
|
-
return { uri, name, type };
|
|
284
|
+
return { uri, name, type: contentType };
|
|
278
285
|
};
|
|
279
286
|
var getFormData = () => new FormData();
|
|
280
287
|
|
|
@@ -464,6 +471,10 @@ function retryIfFailed(fn, options) {
|
|
|
464
471
|
}));
|
|
465
472
|
}
|
|
466
473
|
|
|
474
|
+
function getStoreValue(store) {
|
|
475
|
+
return typeof store === 'undefined' ? 'auto' : store ? '1' : '0';
|
|
476
|
+
}
|
|
477
|
+
|
|
467
478
|
/**
|
|
468
479
|
* Performs file uploading request to Uploadcare Upload API.
|
|
469
480
|
* Can be canceled and has progress.
|
|
@@ -481,13 +492,13 @@ function base(file, { publicKey, fileName, contentType, baseURL = defaultSetting
|
|
|
481
492
|
file: {
|
|
482
493
|
data: file,
|
|
483
494
|
name: fileName ?? file?.name ?? defaultFilename,
|
|
484
|
-
contentType
|
|
495
|
+
contentType: contentType ?? file?.type ?? defaultContentType
|
|
485
496
|
},
|
|
486
497
|
UPLOADCARE_PUB_KEY: publicKey,
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
498
|
+
UPLOADCARE_STORE: getStoreValue(store),
|
|
499
|
+
signature: secureSignature,
|
|
500
|
+
expire: secureExpire,
|
|
501
|
+
source: source,
|
|
491
502
|
metadata
|
|
492
503
|
}),
|
|
493
504
|
signal,
|
|
@@ -503,10 +514,6 @@ function base(file, { publicKey, fileName, contentType, baseURL = defaultSetting
|
|
|
503
514
|
}), { retryNetworkErrorMaxTimes, retryThrottledRequestMaxTimes });
|
|
504
515
|
}
|
|
505
516
|
|
|
506
|
-
function getStoreValue(store) {
|
|
507
|
-
return typeof store === 'undefined' ? 'auto' : store ? '1' : '0';
|
|
508
|
-
}
|
|
509
|
-
|
|
510
517
|
var TypeEnum;
|
|
511
518
|
(function (TypeEnum) {
|
|
512
519
|
TypeEnum["Token"] = "token";
|