camerja icon indicating copy to clipboard operation
camerja copied to clipboard

Take picture, Expo client suddenly stopped

Open jsmageto opened this issue 7 years ago • 4 comments

Hi,

i'm facing problem, when i take picture, Expo client suddenly stopped without error information

snap = async function(){ if (this.camera) { this.camera.takePictureAsync().then(data => { FileSystem.moveAsync({ from: data, to: ${FileSystem.documentDirectory}photos/Photo_${this.state .photoId}.jpg, }).then(() => { this.setState({ photoId: this.state.photoId + 1, }); Vibration.vibrate(); }); }); } };

how to display the error message?

Thanks

jsmageto avatar Nov 10 '17 07:11 jsmageto

with this still can't show the error

try{ this.camera.takePictureAsync().then(data => { FileSystem.moveAsync({ from: data, to: ${FileSystem.documentDirectory}photos/Photo_${this.state .photoId}.jpg, }).then(() => { this.setState({ photoId: this.state.photoId + 1, }); //Vibration.vibrate(); }); }); }catch(error) { console.log('Error Take pic : '+error); }

jsmageto avatar Nov 10 '17 07:11 jsmageto

Hi, i had the same problem. FileSystem.moveAsync, change field "data" to "data.uri". This change solved problem in my case.

To display error add .catch() after .then()

  this.camera.takePictureAsync()
    .then((data) => {
      FileSystem.moveAsync({
        from: data.uri,
        to: `${FileSystem.documentDirectory}photos/Photo_${this.state.photoId}.jpg`,
      }).then(() => {
        this.setState({
          photoId: this.state.photoId + 1,
        });
        Vibration.vibrate();
      })
        .catch((e) => {
          console.log(e, 'ERROR');
        });
    })
    .catch((e) => {
      console.log(e, 'takePicture ERROR');
    });

mali3days avatar Dec 04 '17 13:12 mali3days

Thanks For this Worked For me!

NaveenDK avatar Dec 05 '17 03:12 NaveenDK

@mali3days you should submit a pull request for this!

samburgers avatar Dec 06 '17 03:12 samburgers