"react-native": "0.31.0",
"react-native-fetch-blob": "^0.9.3",
`let files = images.map((item, index)=> {
return {name: index, filename: index + '.png', data: rnfb.wrap(item.uri)}
});
let option = {
'Content-Type': 'multipart/form-data'
};
rnfb.fetch('POST', 'http://xxxxx/upload', option, files)
.catch(e=>Alert.alert('警告', '数据处理异常。'))`
IOS is no problem, but the Android
RNFetchBlob failed to create request multipart body:TypeError:expected dynamic type string,but had type int64
@cheng0112 , Thank you for reporting this issue, I'll look into it 😄
@cheng0112 , I've found here the problem is. The name property should be a string rather than a number. I think simply change type of index will fix it 👍
let files = images.map((item, index)=> {
- return {name: index, filename: index + '.png', data: rnfb.wrap(item.uri)}
+ return {name: String(index), filename: index + '.png', data: rnfb.wrap(item.uri)} });
let option = {
'Content-Type': 'multipart/form-data'
};
rnfb.fetch('POST', 'http://xxxxx/upload', option, files)
.catch(e=>Alert.alert('警告', '数据处理异常。'))`
@cheng0112 , I've found here the problem is. The
nameproperty should be astringrather than anumber. I think simply change type ofindexwill fix it 👍let files = images.map((item, index)=> { - return {name: index, filename: index + '.png', data: rnfb.wrap(item.uri)} + return {name: String(index), filename: index + '.png', data: rnfb.wrap(item.uri)} }); let option = { 'Content-Type': 'multipart/form-data' }; rnfb.fetch('POST', 'http://xxxxx/upload', option, files) .catch(e=>Alert.alert('警告', '数据处理异常。'))`
Thank you so much!!! I was all over on the internet due to this. Params are not accepting if it's not a string.
Most helpful comment
@cheng0112 , I've found here the problem is. The
nameproperty should be astringrather than anumber. I think simply change type ofindexwill fix it 👍