1
votes

i am using react-native-camera to take picture in react native but when sending image to backend it gives network error i have used axios post, i am getting this captured image path in console Path of image: file:///data/user/0/com.rnapp/cache/Camera/0d33d840-af31-4375-bd30-515c1a257ea3.jpg

but when uploading/sending image to backend using axios post it give
[Error: Network Error]

thanks

1

1 Answers

0
votes

You need to read file first then try to upload. Please specify more details about how you are doing. Im using rn-fetch-blob to do this. Assuming file contains your file captured from Camera, below will be the code.

RNFetchBlob.fetch('PUT', 'url', {
            'Content-Type': 'content type of your document',
            'Accept': 'application/json'
        }, RNFetchBlob.wrap(file.filepath)).then(() => {}, () => {})