@uploadcare/upload-client 6.1.0-alpha.0 → 6.1.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 CHANGED
@@ -430,6 +430,8 @@ See [docs][uc-file-metadata] and [REST API][uc-docs-metadata] for details.
430
430
 
431
431
  ## React Native
432
432
 
433
+ ### Prepare
434
+
433
435
  To be able to use `@uploadcare/upload-client` with React Native, you need to
434
436
  install [react-native-url-polyfill][react-native-url-polyfill].
435
437
 
@@ -437,6 +439,27 @@ To prevent [`Error: Cannot create URL for blob`][react-native-url-polyfill-issue
437
439
  errors you need to configure your Android app schema to accept blobs -
438
440
  have a look at this pull request for an example: [5985d7e][react-native-url-polyfill-example].
439
441
 
442
+ 1. Add the following code to the `application` section of your `AndroidManifest.xml`:
443
+
444
+ ```xml
445
+ <provider
446
+ android:name="com.facebook.react.modules.blob.BlobProvider"
447
+ android:authorities="@string/blob_provider_authority"
448
+ android:exported="false"
449
+ />
450
+ ```
451
+
452
+ 2. Add the following code to the `android/app/src/main/res/values/strings.xml`:
453
+
454
+ ```xml
455
+ <resources>
456
+ <string name="app_name">MY_REACT_NATIVE_APP_NAME</string>
457
+ <string name="blob_provider_authority">com.detox.blob</string>
458
+ </resources>
459
+ ```
460
+
461
+ ### Usage
462
+
440
463
  You can use `ReactNativeAsset` as an input to the `@uploadcare/upload-client` like this:
441
464
 
442
465
  ```ts
@@ -457,7 +480,11 @@ Or `Blob` like this:
457
480
  ```ts
458
481
  const uri = 'URI_TO_FILE'
459
482
  const blob = await fetch(uri).then((res) => res.blob())
460
- uploadFile(blob, { publicKey: 'YOUR_PUBLIC_KEY' })
483
+ uploadFile(blob, {
484
+ publicKey: 'YOUR_PUBLIC_KEY',
485
+ fileName: 'file.txt',
486
+ contentType: 'text/plain'
487
+ })
461
488
  ```
462
489
 
463
490
  ## Testing
@@ -390,7 +390,7 @@ const getUrl = (base, path, query) => {
390
390
  return url.toString();
391
391
  };
392
392
 
393
- var version = '6.0.0';
393
+ var version = '6.1.0';
394
394
 
395
395
  const LIBRARY_NAME = 'UploadcareUploadClient';
396
396
  const LIBRARY_VERSION = version;
@@ -437,11 +437,7 @@ const getContentType = (file) => {
437
437
  if (isBlob(file) || isFile(file) || isReactNativeAsset(file)) {
438
438
  contentType = file.type;
439
439
  }
440
- if (contentType) {
441
- return contentType;
442
- }
443
- console.warn(`Cannot determine content type. Using default content type: ${defaultContentType}`, file);
444
- return defaultContentType;
440
+ return contentType || defaultContentType;
445
441
  };
446
442
 
447
443
  const getFileName = (file) => {
@@ -455,11 +451,7 @@ const getFileName = (file) => {
455
451
  else if (isReactNativeAsset(file) && file.name) {
456
452
  filename = file.name;
457
453
  }
458
- if (filename) {
459
- return filename;
460
- }
461
- console.warn(`Cannot determine filename. Using default filename: ${defaultFilename}`, file);
462
- return defaultFilename;
454
+ return filename || defaultFilename;
463
455
  };
464
456
 
465
457
  function getStoreValue(store) {
@@ -418,7 +418,7 @@ const getUrl = (base, path, query) => {
418
418
  return url.toString();
419
419
  };
420
420
 
421
- var version = '6.0.0';
421
+ var version = '6.1.0';
422
422
 
423
423
  const LIBRARY_NAME = 'UploadcareUploadClient';
424
424
  const LIBRARY_VERSION = version;
@@ -465,11 +465,7 @@ const getContentType = (file) => {
465
465
  if (isBlob(file) || isFile(file) || isReactNativeAsset(file)) {
466
466
  contentType = file.type;
467
467
  }
468
- if (contentType) {
469
- return contentType;
470
- }
471
- console.warn(`Cannot determine content type. Using default content type: ${defaultContentType}`, file);
472
- return defaultContentType;
468
+ return contentType || defaultContentType;
473
469
  };
474
470
 
475
471
  const getFileName = (file) => {
@@ -483,11 +479,7 @@ const getFileName = (file) => {
483
479
  else if (isReactNativeAsset(file) && file.name) {
484
480
  filename = file.name;
485
481
  }
486
- if (filename) {
487
- return filename;
488
- }
489
- console.warn(`Cannot determine filename. Using default filename: ${defaultFilename}`, file);
490
- return defaultFilename;
482
+ return filename || defaultFilename;
491
483
  };
492
484
 
493
485
  function getStoreValue(store) {
@@ -398,7 +398,7 @@ const getUrl = (base, path, query) => {
398
398
  return url.toString();
399
399
  };
400
400
 
401
- var version = '6.0.0';
401
+ var version = '6.1.0';
402
402
 
403
403
  const LIBRARY_NAME = 'UploadcareUploadClient';
404
404
  const LIBRARY_VERSION = version;
@@ -445,11 +445,7 @@ const getContentType = (file) => {
445
445
  if (isBlob(file) || isFile(file) || isReactNativeAsset(file)) {
446
446
  contentType = file.type;
447
447
  }
448
- if (contentType) {
449
- return contentType;
450
- }
451
- console.warn(`Cannot determine content type. Using default content type: ${defaultContentType}`, file);
452
- return defaultContentType;
448
+ return contentType || defaultContentType;
453
449
  };
454
450
 
455
451
  const getFileName = (file) => {
@@ -463,11 +459,7 @@ const getFileName = (file) => {
463
459
  else if (isReactNativeAsset(file) && file.name) {
464
460
  filename = file.name;
465
461
  }
466
- if (filename) {
467
- return filename;
468
- }
469
- console.warn(`Cannot determine filename. Using default filename: ${defaultFilename}`, file);
470
- return defaultFilename;
462
+ return filename || defaultFilename;
471
463
  };
472
464
 
473
465
  function getStoreValue(store) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uploadcare/upload-client",
3
- "version": "6.1.0-alpha.0",
3
+ "version": "6.1.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.0.0",
81
+ "@uploadcare/api-client-utils": "^6.1.0",
82
82
  "chalk": "^4.1.2"
83
83
  },
84
84
  "dependencies": {