itinance / itinance/react-native-fs

How to upload a file ? Request for proper syntax. Socket Closed

Open
#873 5 comments 4 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
5k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

I am using `react-native-image-picker` to get the image properties and use the below code to push the files to my server. I am getting a socket closed error. Can you please suggest me the valid syntax to upload a image file in android as well as in ios.

export function postImage(state) {
return RNFS.uploadFiles({
toUrl: $http.defaults.baseURL + '/image/save',
files: [
{
filepath: RNFS.ExternalStorageDirectoryPath + state.photo.fileName,
filetype: state.photo.type,
name: state.photo.fileName,
filename: state.photo.fileName
}
],
method: 'POST',
headers: {
'content-type': 'multipart/form-data'
},
fields: {
'hello': 'world',
},
}).promise
.then(response => response)
.catch(error => alert(JSON.stringify(error)));
}

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.