GithubHelp home page GithubHelp logo

satya164 / react-native-image-chooser Goto Github PK

View Code? Open in Web Editor NEW
26.0 4.0 5.0 68 KB

A React Native module to show system Image chooser. Currently only supports Android.

License: MIT License

Java 98.25% JavaScript 1.75%

react-native-image-chooser's Introduction

react-native-image-chooser

A React Native module to show system Image chooser. Currently only supports Android.

Installation

npm i --save react-native-image-chooser

Add it to your android project

In android/settings.gradle

...

include ':react-native-image-chooser'
project(':react-native-image-chooser').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-chooser/android')

In android/app/build.gradle

...

dependencies {
    ...

    compile project(':react-native-image-chooser')
}

Register module (in MainActivity.java)

import com.imagechooser.ImageChooserPackage;  // <--- import

public class MainActivity extends ReactActivity {

  ......

  @Override
  protected List<ReactPackage> getPackages() {
    return Arrays.asList(
      new MainReactPackage(),
      new ImageChooserPackage() // <------ add the package
    );
  }

  ......

}

Usage

First import the module as follows:

import ImageChooser from "react-native-image-chooser";

To show the chooser, call the pickImage method:

try {
  const data = await ImageChooser.pickImage();

  // do something with the data
} catch (err) {
  // handle error
}

The pickImage method returns a Promise with data. The data object has the following properties:

height: number;
width: number;
size: number;
name: string;
uri: string;

react-native-image-chooser's People

Contributors

satya164 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-native-image-chooser's Issues

How do I send image to server?

Hi
The uri result to js end is

image:', { uri: 'content://com.google.android.apps.photos.contentprovider/-1/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F31/ACTUAL/1548463300',

But How do I use this uri, send to server and show to users.

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.