I am new to react native I am using react native camera library for capturing the image. I have captured the image now I want it to save on application folder like on assets or src folder. I have the image uri.How I can do that plz let me know.
state = {
cameraType: "back",
mirrorMode: false,
path: null,
};
<View>
<RNCamera
ref={(ref) => (this.camera = ref)}
mirrorImage={this.state.mirrorMode}
style={styles.preview}
type={RNCamera.Constants.Type.front}
flashMode={RNCamera.Constants.FlashMode.on}
androidCameraPermissionOptions={{
title: "Permission to use camera",
message: "We need your permission to use your camera",
buttonPositive: "Ok",
buttonNegative: "Cancel",
}}
androidRecordAudioPermissionOptions={{
title: "Permission to use audio recording",
message: "We need your permission to use your audio",
buttonPositive: "Ok",
buttonNegative: "Cancel",
}}
/>
<Button onPress={() => this.takePicture()} style={styles.btncontainer}>
<Text>Take Picture</Text>
</Button>
</View>
takePicture = async () => {
if (this.camera) {
const options = { quality: 0.5, base64: true };
const data = await this.camera.takePictureAsync(options);
this.setState({ path: data.uri });
console.log("url", this.state.path);
}
};
console.log
url file:///data/user/0/com.tracking/cache/Camera/231f7d30-f74c-4f6d-b955-284b108592ca.jpg