Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Difficulties handling asynchronous taks using image-picker and copying files in react-native

const copyPhoto = (source, destination) => {
  if (source === undefined || destination === undefined) {
    return;
  } else {
    RNFS.copyFile(source, destination)
      .then((result) => {
        console.log("

>>>>>>>>>>>>The photo has been copied ");
      })
      .catch((error) => {
        console.log("

>>>>>>>>>>>>Copy photo failed: ", error);
      });
  }
};

const onCameraPress = async () => {
  const options = {
    saveToPhotos: true,
    mediaType: "photo",
    includeBase64: false
  };
  const result = await ImagePicker.launchCamera(options);

  //if the user cancelled the process
  if (result.didCancel) {
    return alert("You cancelled the process");
  }

  const {assets} = result;

  if (assets.length > 0) {
    const decodedUri = decodeURIComponent(assets[0].uri);
    copyPhoto(decodedUri, photoPath);
  }
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: .push( ) is not updating the variable 
Javascript :: Page Pre loader not removing 
Javascript :: How to use search/filter for HTML Divs generated from JSON data using JavaScript 
Javascript :: Save multiple radios checked on LocalStorage 
Javascript :: javascript include array value in an object property in an array map some 
Javascript :: fill array with random numbers javascript using arrow function 
Javascript :: reduce dot notations to javascript array 
Javascript :: fields filtering in api from express 
Javascript :: Node.js with Express: Importing client-side javascript using script tags in Jade views 
Javascript :: yaml request body json 
Javascript :: nextjs app wdyr 
Javascript :: store api key in environment variable ngular 
Javascript :: nodejs passport starter template with username and password 
Javascript :: Remove # id From URL When Clicked On Href Link 
Javascript :: create a group or pool in phaser 
Javascript :: react native ios accessibility font size 
Javascript :: Sorting the Odd way! 
Javascript :: var a = x || y Variable Assignment In JavaScript 
Javascript :: js a || b 
Javascript :: board in javascript 
Javascript :: prisma multiple relation counts 
Javascript :: es6 javascript return types 
Javascript :: magnetic button vanilla js 
Javascript :: pnpm tailwind react 
Javascript :: get data from multiple api in react 
Javascript :: Proper Way To Access Model(s) Data From Collection In Backbone 
Javascript :: Backbone View In Another View 
Javascript :: js onclick add table row 
Javascript :: jquery if element has multiple classes 
Javascript :: moment add 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =