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
0
votes
1 answer

React native image upload getting network error

'react-native-image-picker' for uploading image in my application, Sometimes it is uploading and sometimes i am getting [TypeError: Network request failed] below is the code: FormData in my component: //image is…
0
votes
0 answers

How can I detect if picked video is 4K?

Is it possible to check if picked video is 4K in React Native? I don't want users to be able to upload 4K videos, so how I can handle this? Im using react-native-image-crop-picker.
AlmaG3st
  • 192
  • 9
0
votes
0 answers

Saving User Profile Picture to s3 and a Link to Mongodb Using a PUT Request

I'm using a PUT request to upload a user's profile picture to s3 and save a link to it in my MongoDB users collection. For some reason, I'm getting "CLIENT_ERROR". Obviously, there's some error in my implementation. Below are the steps I've taken…
0
votes
0 answers

I cant able to send in image data to my server using RNFetchBlob in react native

I am making a image upload page. i used 2 library 1.react-native-image-picker and rn-fetch-blob. when i perform a script it's show an error like "RNFetchBlob failed to create request multipart body :Value for data cannot be cast from…
0
votes
1 answer

React Native ImagePicker showImagePicker alternative

I've found out that with the newest version of react-native-image-picker the showImagePicker no longer exists. Is there any other native way we can still implement the functionality of showing us the ActionSheet of "Take photo", "Choose from…
Ken
  • 1,155
  • 2
  • 19
  • 36
0
votes
1 answer

How to upload files from react native app to PHP server?

I developed a PHP project, now I am working on connecting it to react native app. However, I tried many codes to upload image to the server nothing works. Here is my code example, const uploadImage = async () => { // Check if any file is selected…
0
votes
0 answers

Having problems while trying to send two images to Backend via FormData

I'm trying to replicate this Postman Request on React Native. In this case, I'm taking two pictures with launchCamera and adding them to the DataForm, but it's not arriving succesfully on the backend. This is the Postman Request I need to…
0
votes
1 answer

react-native-image-picker callback is not a function

I'm new to react native and in my sample app I can't handle properly results returned from ImagePicker of this component https://github.com/react-native-image-picker/react-native-image-picker I'm running react 0.65 and below is my code: import * as…
0
votes
0 answers

How to preview video from react-native-image-picker in react native cli

I'm working on a react native CLI, pure JavaScript eCommerce mobile application that requires users to upload a short video of 30 seconds. The design is that you upload and preview the video before sending it to the API. What is the best package to…
0
votes
2 answers

How to reset Camera Permission in expo-image-picker?

I have just started to use expo-image-picker but for testing purposes I have denied the camera permissions so many times that I'm not being asked anymore whether I want to allow or deny the permission. I have refreshed, relaunched the app but…
Laspeed
  • 791
  • 1
  • 5
  • 27
0
votes
1 answer

Issue with Expo Image Picker at build time

This is the error I am facing at the time of building the ios for my expo app. Here is the code for Image Picker I used This is working great in my simulator expo app as well as in iphone expo as well but giving this error while building using eas…
Adhikansh Mittal
  • 601
  • 1
  • 5
  • 13
0
votes
0 answers

react-native image picker not asking for gallery permission in iOS app

These are the steps mentioned in the package and I have followed everything: Add the appropriate keys to your Info.plist, If you are allowing user to select image/video from photos, add NSPhotoLibraryUsageDescription. If you are allowing user to…
0
votes
0 answers

How to save an image from React Native Image Picker to a database?

I am using MongoDB for my database and want users in my app to be able to pick a profile picture. I am using expo-image-picker to select the image and then I save the result.uri to the database. An example of what I see in the database is:…
Cole
  • 207
  • 2
  • 11
0
votes
1 answer

possible unhandled promise rejection_Expo Image Picker

I want to use Expo Image Picker, but I'm getting the following error. 'Console Warning : possible unhandled promise rejection (id : 0)'. I already installed 'expo-image-picker'. Here's the promise code, I don't see what's wrong here, any ideas? …
이소민
  • 21
  • 1
0
votes
1 answer

expo-image-picker translate buttons on iOS

I need to change the text (translate to my language) when the user choose to take a photo from camera on iOS. I didn't find anything in docs. On android the buttons appear with the language configured on the device, but on iPhone the text of the…
Edinho Rodrigues
  • 354
  • 4
  • 24