1.2.3 • Published 6 years ago

react-native-upload-image-expo v1.2.3

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

Codeship Status for br4in3x/react-native-upload-image-expo

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={(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

PropertyTypeDescriptionRequired
endpointstringYour server's endpointYes
methodenum: 'POST', 'PUT', 'PATCH'Query methodYes
payloadKeystringThe key in the payload object to server { "photo": {...} }Yes
headersObjectArray of headers for the server request. Useful for authorization.No
onSuccessFunction(image, rawResponse)A function called after upload succeedsNo
onFailureFunction(error)A function called if upload failsNo
onStartUploadFunctionA function called before upload beginsNo

iOS specific options

PropertyTypeDescriptionRequiredDefault
alertMessagestringA message shown to the user in case if he denies access to photo libraryNoThis applicaton needs access to your photo library to upload images. Please go to Settings of your device and grant permissions to Photos.
alertTitlestringTitle for that messageNoPlease Allow Access
alertNostringCancel button text for alertNoNot Now
alertYesstringText for button which forwards user to the settings pageNoSettings
1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago