WeCan
WeCan

Reputation: 597

React-Native ENOENT: no such file or directory, open'assets-library://asset/asset.jpg' in Xcode

Hi while uploading the picture from iPhone using react-native-fs in my react-native app. I am getting below error.

enter image description here

How to fix this above issue.

Upvotes: 1

Views: 672

Answers (1)

WeCan
WeCan

Reputation: 597

I fixed the above issue by adding this captureTarget={Camera.constants.CaptureTarget.disk} line of code in my file.

import React, {Component} from 'react';
import {
    StyleSheet,
    Text,
    View
} from 'react-native';
import Camera from 'react-native-camera';
import RNFS from 'react-native-fs';

export default class App extends Component {
    render() {
        return (
            <View style={styles.container}>
                <View style={styles.titlebar}>
                    <Text style={styles.title}>Welcome {this.props.navigation.getParam('FirstName', '')}</Text>
                </View>
                <Camera
                    ref={(cam) => {
                        this.camera = cam;
                    }}
                    type={'front'}
                    style={styles.preview}
                    aspect={Camera.constants.Aspect.fill}
                    captureQuality={Camera.constants.CaptureQuality.low}
                    captureTarget={Camera.constants.CaptureTarget.disk}
                >
                    <View>
                        <View style={styles.buttoncontainer}>
                            {
                                this.props.navigation.getParam('LogType', '') &&
                                <Text style={styles.in} onPress={this.takePicture.bind(this)}>IN</Text>
                            }
                            {!this.props.navigation.getParam('LogType', '') &&
                            <Text style={styles.out} onPress={this.takePicture.bind(this)}>OUT</Text>
                            }
                        </View>
                    </View>
                </Camera>
            </View>
        );
    }

    takePicture() {
        this.camera.capture()
            .then((data) =>
                this.ServiceCall(data)
            )
            .catch(err => console.error(err));
    }

}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: 'white'
    },
    title: {
        flex: 1,
        alignSelf: 'center',
        fontSize: 30,
        color: 'black',
        backgroundColor: 'white'
    },
    titlebar: {
        flexDirection: 'row',
        backgroundColor: 'white',
        paddingTop: 10,
        paddingBottom: 10,
        paddingLeft: 5
    },
    buttoncontainer: {
        flexDirection: 'row',
    },
    preview: {
        flex: 1,
        justifyContent: 'flex-end',
        alignItems: 'center'
    },
    in: {
        fontSize: 30,
        backgroundColor: 'green',
        marginBottom: 20,
        padding: 20,
        color: 'white',
        borderRadius: 10,
        textAlign: 'center'
    },
    out: {
        fontSize: 30,
        padding: 20,
        backgroundColor: 'red',
        marginBottom: 20,
        color: 'white',
        borderRadius: 10,
        textAlign: 'center'
    },
});
strong text

Upvotes: 1

Related Questions