Giter Site home page Giter Site logo

shravanmeena / react-native-upload-image-expo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from max-pv/react-native-upload-image-expo

0.0 0.0 0.0 238 KB

A react-native component for uploading image with Expo ImagePicker API

License: MIT License

JavaScript 100.00%

react-native-upload-image-expo's Introduction

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

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

react-native-upload-image-expo's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.