Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@r4dic4l/react-native-image-picker
Advanced tools
A React Native module that allows you to use native UI to select media from the device library or directly from the camera
This is a fork of react-native-image-picker.
A React Native module that allows you to use native UI to select a photo/video from the device library or directly from the camera.
react-native-image-picker
is working on simplifying the codebase and API. Feel free read through the discussions here: GH-1358.
This library started as a basic bridge of the native iOS image picker, and I want to keep it that way. As such, functionality beyond what the native UIImagePickerController
supports will not be supported here. Multiple image selection, more control over the crop tool, and landscape support are things missing from the native iOS functionality - not issues with this library. If you need these things, react-native-image-crop-picker might be a better choice for you.
To use this library you need to ensure you match up with the correct version of React Native you are using.
p.s. React Native introduced AndroidX support in 0.60, which is a breaking change for most libraries (incl. this one) using native Android functionality.
react-native-image-picker version | Required React Native Version |
---|---|
1.x.x OR 2.x.x | >= 0.60 or >= 0.59 if using Jetifier |
0.x.x | <= 0.59 |
npm install @r4dic4l/react-native-image-picker
# RN >= 0.60
npx pod-install
# RN < 0.60
react-native link @r4dic4l/react-native-image-picker
You will also need to add UsageDescription
on iOS and some permissions on Android, refer to the Install doc.
import ImagePicker from '@r4dic4l/react-native-image-picker';
// More info on all the options is below in the API Reference... just some common use cases shown here
const options = {
title: 'Select Avatar',
customButtons: [{ name: 'fb', title: 'Choose Photo from Facebook' }],
storageOptions: {
skipBackup: true,
path: 'images',
},
};
/**
* The first arg is the options object for customization (it can also be null or omitted for default options),
* The second arg is the callback which sends object: response (more info in the API Reference)
*/
ImagePicker.showImagePicker(options, (response) => {
console.log('Response = ', response);
if (response.didCancel) {
console.log('User cancelled image picker');
} else if (response.error) {
console.log('ImagePicker Error: ', response.error);
} else if (response.customButton) {
console.log('User tapped custom button: ', response.customButton);
} else {
const source = { uri: response.uri };
// You can also display the image using data:
// const source = { uri: 'data:image/jpeg;base64,' + response.data };
this.setState({
avatarSource: source,
});
}
});
Then later, if you want to display this image in your render() method:
<Image source={this.state.avatarSource} style={styles.uploadAvatar} />
To Launch the Camera or Image Library directly (skipping the alert dialog) you can do the following:
// Launch Camera:
ImagePicker.launchCamera(options, (response) => {
// Same code as in above section!
});
// Open Image Library:
ImagePicker.launchImageLibrary(options, (response) => {
// Same code as in above section!
});
On iOS, don't assume that the absolute uri returned will persist. See react-native-image-picker #107
For more, read the API Reference.
FAQs
A React Native module that allows you to use native UI to select media from the device library or directly from the camera
We found that @r4dic4l/react-native-image-picker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.