File tree 1 file changed +28
-1
lines changed
1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -430,13 +430,36 @@ 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
436
438
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
You can’t perform that action at this time.
0 commit comments