itinance / itinance/react-native-fs
How to upload a file ? Request for proper syntax. Socket Closed
- 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.