react-native-fs
react-native-fs copied to clipboard
cannot be cast from Double to String for android
"react": "16.9.0", "react-native": "0.61.5", "react-native-fs": "2.16.4",
below code work properly in ios but not working on android it getting error casting error
var data = new Object();
data['intUserId'] = 5;
data['intActivityId'] = 8;
data['strStatus'] = 'OK';
RNFS.uploadFiles({
toUrl: url,
files: [{
name: fileKey,
filename: file.name,
filetype: file.type,
filepath: filePath,
}],
method: 'POST',
headers: {
//'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
//'Accept': 'application/json',
'Accept': 'multipart/form-data',
'Authorization': 'Basic ' + Base64.btoa(basicAuthUserName + ':' + basicAuthPassword),
},
fields: data,
begin: ()=>{console.log("Uploading start")},
progress: (response) => {
var percentage = Math.floor((response.totalBytesSent/response.totalBytesExpectedToSend) * 100);
console.log('UPLOAD IS ' + percentage + '% DONE!');
}
})
.promise.then((response) => {
console.log(JSON.stringify(response));
if (response.statusCode == 200) {
console.log("FILES UPLOADED!");
console.log("Response :" + response.body);
} else {
console.log("SERVER ERROR");
}
})
.catch((error) => {
console.log("Exception :- " + error);
//alert("Exception :- " + error);
});
Exception :- Error: Value for intUserId cannot be cast from Double to String
I'm seeing the same. If we look at the Typescript definition for Fields.
type Fields = { [name: string]: string }
It would appear it only accepts strings.
This can be worked around in the backend of course, but surely any JSON-able type should be permitted?
cannot be cast from Double to String for android, facing the same, please resolve this @itinance