Skip to content

Commit ed04c9c

Browse files
committed
chore(upload-client): update readme
1 parent 87efbb2 commit ed04c9c

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

packages/upload-client/README.md

+28-1
Original file line numberDiff line numberDiff line change
@@ -430,13 +430,36 @@ See [docs][uc-file-metadata] and [REST API][uc-docs-metadata] for details.
430430
431431
## React Native
432432
433+
### Prepare
434+
433435
To be able to use `@uploadcare/upload-client` with React Native, you need to
434436
install [react-native-url-polyfill][react-native-url-polyfill].
435437
436438
To prevent [`Error: Cannot create URL for blob`][react-native-url-polyfill-issue]
437439
errors you need to configure your Android app schema to accept blobs -
438440
have a look at this pull request for an example: [5985d7e][react-native-url-polyfill-example].
439441
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+
440463
You can use `ReactNativeAsset` as an input to the `@uploadcare/upload-client` like this:
441464
442465
```ts
@@ -457,7 +480,11 @@ Or `Blob` like this:
457480
```ts
458481
const uri = 'URI_TO_FILE'
459482
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+
})
461488
```
462489

463490
## Testing

0 commit comments

Comments
 (0)