# react-native-upload-image-expo

> Render props style component for uploading image with Expo.ImagePicker API

Latest version **1.2.3** (published 2018-07-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-upload-image-expo
pnpm add react-native-upload-image-expo
yarn add react-native-upload-image-expo
bun add react-native-upload-image-expo
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.3 |
| Published | 2018-07-31 |
| First published | 2018-07-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 11.4 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Max Pimenov |
| Maintainers | br4in3x |
| Keywords | react-native, image, upload, uploader, expo, image-upload |

## Links

- npm: https://www.npmjs.com/package/react-native-upload-image-expo
- Repository: https://github.com/br4in3x/react-native-upload-image-expo
- Issues: https://github.com/br4in3x/react-native-upload-image-expo/issues
- npm.io page: https://npm.io/package/react-native-upload-image-expo

## Dependencies (4)

- [expo](https://npm.io/package/expo.md) ^28.0.0
- [uuid](https://npm.io/package/uuid.md) ^3.3.2
- [react](https://npm.io/package/react.md) ^16.4.1
- [prop-types](https://npm.io/package/prop-types.md) ^15.6.2

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 1.2.3 (latest) — 2018-07-31
- 1.2.2 — 2018-07-30
- 1.2.1 — 2018-07-28
- 1.2.0 — 2018-07-28
- 1.1.0 — 2018-07-26
- 1.0.1 — 2018-07-25
- 1.0.0 — 2018-07-24

## README

[![Codeship Status for br4in3x/react-native-upload-image-expo](https://app.codeship.com/projects/dc531a00-7138-0136-89ed-66ecdb7845e3/status?branch=master)](https://app.codeship.com/projects/299161)

### About

This component is a convenient wrapper around [example of image handling](https://github.com/expo/image-upload-example) from Expo team.

### Installation

```
npm i react-native-upload-image-expo
```

### Usage

See [example](https://github.com/br4in3x/react-native-upload-image-expo/blob/master/example/App.js):

```javascript
<ImageUploadExpo
  method="POST"
  endpoint="https://file-upload-example-backend-dkhqoilqqn.now.sh/upload"
  payloadKey="photo"
  onFailure={(error) => console.warn(error)}
  onSuccess={(image, rawResponse) => {
    console.log(`Image URL: ${image.location}`);
    console.log('headers: ', rawResponse.headers);
  }}
  onStartUpload={() => console.log('Upload has begun!')}
  headers={{
    'uid': '...',
    'client': '...',
    'access-token': '...',
  }}
>
  {props => (
    <TouchableOpacity
      onPress={props.askPermission}
    >
      <ImageUI
        loading={props.loading}
        error={props.error}
        image={props.image}
      />
    </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                                                                                                                                   |

---
_Source: https://npm.io/package/react-native-upload-image-expo · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
