Questions tagged [react-native-image-picker]

This package is the basic package by react native community to upload an image from your gallery or camera.

This is the way it opens on click in iOS

This way it opens in android on a click

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. You have to specify both permission of accessing camera and gallery in both platforms(android and iOS).

A code snippet to simplify:

import ImagePicker from '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, you can display this image in your render() method.

304 questions
4
votes
0 answers

react-native-fs library is not moving or copying files - weird results

npmPackages: @react-native-community/cli: ^4.13.0 => 4.13.0 react: 16.13.1 => 16.13.1 react-native: 0.63.3 => 0.63.3 react-native-windows: Not Found react-native-fs: ^2.16.6 react-native-image-picker: ^2.3.4 IDEs: …
4
votes
0 answers

react-native-image-picker: value returned from showImagePicker doesnt tell you if user blocked permission (Android)

I want user to select a profile picture using either camera or photo gallery. I use react-native-image-picker to give user choice.....using below code: import ImagePicker from 'react-native-image-picker'; export const _imagePickHandler = userId =>…
4
votes
0 answers

React Native: Get Duration of local video

I am currently using react-native-image-picker to allow a user to select a video from their gallery. I am trying to disallow them from uploading a video that is greater than 'X' number of seconds. Is there anyway to programmatically retrieve the…
dmouawad
  • 539
  • 1
  • 5
  • 13
4
votes
1 answer

The module react-native-image-picker in iOS always requires microphone permissions although I don't select video, only camera

I'm using react-native-image-picker (to take photos / to select photos) to upload them to my server. It works perfectly. To do this I use an ImagePicker. The problem comes when I notice that in iOS, if I want to use it, the module requires me the…
SmoggeR_js
  • 2,950
  • 4
  • 22
  • 52
4
votes
2 answers

Firebase Storage: string does not match format base64: invalid character found. Only when debug is off

I'm trying to upload an image file to firebase storage, save the download URL, and load it after the upload is completed. When I run the app with debug js remotely on it works fine. When I turn off debug mode it stops working with the invalid format…
4
votes
1 answer

React-native-image-picker: How to access gallery images directly in grid fashion

I am using react-native-image-picker and I would like to access gallery images directly from the device. However, when I launch ImageLibrary using the following method, I would see further 2 options saying "Pictures", "Download". Instead I would…
Inaccessible
  • 1,560
  • 3
  • 18
  • 42
3
votes
0 answers

react-native-image-picker uri to file to node js backend

I am working on a react-native social app and trying to upload a post image from react-native using react-native-image-picker and typescript. I am able to get Image uri but have to create file/blob to send it to node js backend const…
3
votes
1 answer

Expo-image-picker: "Unhandled promise rejection: Error: Failed to write data to a file"

I am building a react native multiuser app and I am trying to set up the user profile page. I am trying to make a user profile picture that a user can upload from their image library. I manage to open the image gallery but when I select an image I…
3
votes
2 answers

React native sends empty req.body and undefined req.file to nodejs multer

Im using react-native and nodejs(multer). In nodejs I receive req.body-{}, req.file-undefined and req.files-undefined I checked everything in stackoverflow and nothing works. Here is my code. Client code(react native): const onPressOpenLibrary =…
3
votes
0 answers

React Native how to open document picker from specific path

i am create one Image Editor application and for that i have some requirements that user can Edit that image that present in App Internal path (data/data/com.myapp/files) for that i have done open gallery and import (copy) in inside…
3
votes
5 answers

Cannot read property 'launchImageLibrary' of undefined react-native-image-picker

My feature offers a small image icon as a touchable to upload or take a picture, using "react-native-image-picker": "^3.3.2". I'm getting error: Cannot read property 'launchImageLibrary' of undefined, same as this GitHub issue but as you can see, my…
lsilva
  • 147
  • 2
  • 17
3
votes
0 answers

react native app crash on react-native-image-picker

I am using react-native-image-picker library to upload the image, it crashes the app when i select any image from gallery to upload. I am sharing the piece of code of it. import { launchCamera, launchImageLibrary } from…
Chandler Bing
  • 293
  • 4
  • 18
3
votes
2 answers

Trigger an event before the image shown on the screen?

I am trying to implement a triggering event before the image shown on the screen. The snippet below is working properly to pick an image and it's showing on the screen. After clicking the CROP the image is showing on the screen. However, After…
Mamunur Rashid
  • 1,095
  • 17
  • 28
3
votes
2 answers

How can I send image in react-native-gifted-chat?

I want to send image in react-Native-Gifted-chat like sending text. I am novice in react-native. I have already used react-native-image-picker for pick a image from physical device, now I am unable to render image in message[].
3
votes
1 answer

React native image picker causes application to restart without error

I am using react-native-image-picker 2.3.1, react-native 0.63.3 and react 16.3.1. When using the image picker to launch the camera, on some devices (Samsung devices, Android 10, both tablets and phones), after the user takes the picture, the…
Andrei Zafiu
  • 501
  • 6
  • 17
1
2
3
20 21