From ed04c9c991a3a832cef2263b98f40824bcbbe4d1 Mon Sep 17 00:00:00 2001 From: nd0ut Date: Thu, 29 Dec 2022 20:57:33 +0400 Subject: [PATCH] chore(upload-client): update readme --- packages/upload-client/README.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/upload-client/README.md b/packages/upload-client/README.md index 99287650e..16867acaf 100644 --- a/packages/upload-client/README.md +++ b/packages/upload-client/README.md @@ -430,6 +430,8 @@ See [docs][uc-file-metadata] and [REST API][uc-docs-metadata] for details. ## React Native +### Prepare + To be able to use `@uploadcare/upload-client` with React Native, you need to install [react-native-url-polyfill][react-native-url-polyfill]. @@ -437,6 +439,27 @@ To prevent [`Error: Cannot create URL for blob`][react-native-url-polyfill-issue errors you need to configure your Android app schema to accept blobs - have a look at this pull request for an example: [5985d7e][react-native-url-polyfill-example]. +1. Add the following code to the `application` section of your `AndroidManifest.xml`: + +```xml + +``` + +2. Add the following code to the `android/app/src/main/res/values/strings.xml`: + +```xml + + MY_REACT_NATIVE_APP_NAME + com.detox.blob + +``` + +### Usage + You can use `ReactNativeAsset` as an input to the `@uploadcare/upload-client` like this: ```ts @@ -457,7 +480,11 @@ Or `Blob` like this: ```ts const uri = 'URI_TO_FILE' const blob = await fetch(uri).then((res) => res.blob()) -uploadFile(blob, { publicKey: 'YOUR_PUBLIC_KEY' }) +uploadFile(blob, { + publicKey: 'YOUR_PUBLIC_KEY', + fileName: 'file.txt', + contentType: 'text/plain' +}) ``` ## Testing