@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.
@@ -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 (typeof asset === 'object' &&
269
- !!asset &&
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
- // UPLOADCARE_STORE: getStoreValue(store),
482
- // signature: secureSignature,
483
- // expire: secureExpire,
484
- // source: source,
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";
@@ -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 (typeof asset === 'object' &&
293
- !!asset &&
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
- // UPLOADCARE_STORE: getStoreValue(store),
506
- // signature: secureSignature,
507
- // expire: secureExpire,
508
- // source: source,
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 (typeof asset === 'object' &&
261
- !!asset &&
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 (typeof file === 'string' && isReactNativeUri(file)) {
273
+ if (isReactNativeUri(file)) {
270
274
  return { uri: file, name, type: contentType };
271
275
  }
272
276
  if (isReactNativeAsset(file)) {
273
- return file;
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
- const type = contentType || file.type;
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
- // UPLOADCARE_STORE: getStoreValue(store),
488
- // signature: secureSignature,
489
- // expire: secureExpire,
490
- // source: source,
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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uploadcare/upload-client",
3
- "version": "6.0.1-alpha.6",
3
+ "version": "6.0.1-alpha.8",
4
4
  "description": "Library for work with Uploadcare Upload API",
5
5
  "type": "module",
6
6
  "module": "./dist/index.node.js",