About
This component is a convenient wrapper around example of image handling from Expo team.
Installation
npm i react-native-upload-image-expo
Usage
See example:
<ImageUploadExpo method="POST" endpoint="https://file-upload-example-backend-dkhqoilqqn.now.sh/upload" payloadKey="photo" onFailure= console onSuccess= { console; console; } onStartUpload= console headers= 'uid': '...' 'client': '...' 'access-token': '...' > <TouchableOpacity onPress=propsaskPermission > <ImageUI loading=propsloading error=propserror image=propsimage /> </TouchableOpacity> </ImageUploadExpo>
Options
Property | Type | Description | Required |
---|---|---|---|
endpoint | string | Your server's endpoint | Yes |
method | enum: 'POST', 'PUT', 'PATCH' | Query method | Yes |
payloadKey | string | The key in the payload object to server { "photo": {...} } |
Yes |
headers | Object | Array of headers for the server request. Useful for authorization. | No |
onSuccess | Function(image, rawResponse) | A function called after upload succeeds | No |
onFailure | Function(error) | A function called if upload fails | No |
onStartUpload | Function | A function called before upload begins | No |
iOS specific options
Property | Type | Description | Required | Default |
---|---|---|---|---|
alertMessage | string | A message shown to the user in case if he denies access to photo library | No | This applicaton needs access to your photo library to upload images. Please go to Settings of your device and grant permissions to Photos. |
alertTitle | string | Title for that message | No | Please Allow Access |
alertNo | string | Cancel button text for alert | No | Not Now |
alertYes | string | Text for button which forwards user to the settings page | No | Settings |