I am Using react-native-fs for sending the files I picked by react-native-document-picker.
so I make a function and call it when all the required files are selected like the code below.
and when I call the function
uploadImageReq()
I got the following error on console
ERROR Error: unexpected end of stream
at Object.promiseMethodWrapper [as uploadFiles] (NativeModules.js:103)
at Object.uploadFiles (FS.common.js:594)
at uploadImageReq$ (AddScreen.js:73)
at tryCatch (runtime.js:45)
at Generator.invoke [as _invoke] (runtime.js:274)
at Generator.prototype.<computed> [as next] (runtime.js:97)
at tryCatch (runtime.js:45)
at invoke (runtime.js:135)
at runtime.js:170
at tryCallTwo (core.js:45)
the files is
[{name: "imageFile", filename: "IMGs.jpg", filepath: "/data/user/0/com.bookland/cacheNONE/1201418716", filetype: "image/jpeg"},{name: "imageFile", filename: "IMGs.jpg", filepath: "/data/user/0/com.bookland/cacheNONE/1201418716", filetype: "image/jpeg"}]
Thank you for your helps
You need to stringify all of your embeded items:
//Other code onTop
const {location, ...other} = payload;
form.append("location", JSON.stringify(location));
...
and i strongly Recommend you to use RNFetchBlob instead of Axios, dont forget to pass content type in to your header.
great coding