Socket
Socket
Sign inDemoInstall

react-native-image-picker

Package Overview
Dependencies
Maintainers
2
Versions
212
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-image-picker - npm Package Compare versions

Comparing version 0.6.1 to 0.7.0

17

Example/index.ios.js

@@ -30,3 +30,3 @@ import React from 'react-native';

chooseFromLibraryButtonHidden: false,
returnBase64Image: true,
returnBase64Image: false,
returnIsVertical: false,

@@ -36,6 +36,13 @@ quality: 0.2

UIImagePickerManager.showImagePicker(options, (type, response) => {
console.log(type);
if (type !== 'cancel') {
const source = {uri: 'data:image/jpeg;base64,' + response, isStatic: true};
UIImagePickerManager.showImagePicker(options, (responseType, response) => {
console.log(`Response Type = ${responseType}`);
if (responseType !== 'cancel') {
let source;
if (responseType === 'data') { // New photo taken OR passed returnBase64Image true - response is the 64 bit encoded image data string
source = {uri: 'data:image/jpeg;base64,' + response, isStatic: true};
} else { // Selected from library - response is the URI to the local file asset
source = {uri: response.replace('file://', ''), isStatic: true};
}
this.setState({

@@ -42,0 +49,0 @@ avatarSource: source

@@ -7,3 +7,3 @@ {

},
"version": "0.6.1",
"version": "0.7.0",
"description": "A React Native module that allows you to use the native UIImagePickerController UI to select a photo from the device library or directly from the camera.",

@@ -10,0 +10,0 @@ "author": "Marc Shilling (marcshilling)",

@@ -5,2 +5,4 @@ # react-native-image-picker

**Requires iOS 8 or higher**
## Install

@@ -44,15 +46,19 @@ 1. `npm install react-native-image-picker@latest --save`

// The first arg will be the options object for customization, the second is
// your callback which sends string: type, string: response
UIImagePickerManager.showImagePicker(options, (type, response) => {
if (type !== 'cancel') {
var source;
if (type === 'data') { // New photo taken OR passed returnBase64Image true - response is the 64 bit encoded image data string
// your callback which sends string: responseType, string: response.
// responseType will be either 'cancel', 'data', 'uri', or one of your custom button values
UIImagePickerManager.showImagePicker(options, (responseType, response) => {
console.log(`Response Type = ${responseType}`);
if (responseType !== 'cancel') {
let source;
if (responseType === 'data') { // New photo taken OR passed returnBase64Image true - response is the 64 bit encoded image data string
source = {uri: 'data:image/jpeg;base64,' + response, isStatic: true};
} else { // Selected from library - response is the URI to the local file asset
source = {uri: response};
}
else if (responseType === 'uri') { // Selected from library - response is the URI to the local file asset
source = {uri: response.replace('file://', ''), isStatic: true};
}
this.setState({avatarSource:source});
} else {
console.log('Cancel');
this.setState({
avatarSource: source
});
}

@@ -59,0 +65,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc