http
http copied to clipboard
Package fails to send images as base64
Months ago i created a function to send images as base64 to my server in order to save them and it worked. Today i used that function and i am getting a weird exception when i try to post the image.
Here's my function
Uri url = Uri.parse("https://myserver/myApis");
Map data = {
...
...
"method" : method,
"data" : jsonData
};
Map<dynamic, dynamic> result = {};
try {
var response = await http.post(url, body: json.encode(data));
if (response.statusCode == 200) {
Map<String, dynamic> jsonMap = json.decode(response.body);
onSuccess.call(jsonMap);
} else {
onError.call(response.statusCode, response.body);
}
}on Exception catch(error){
// Here i get the weird exception
onError.call(-1234, error.toString());
result.addAll({
"error" : error.toString(),
"errCode" : -1234
});
}
return result;
The exception's message says; "

I tried to build the same method on Java and it works perfectly! Then i tried to send half image, by sending the half base64 string image and it still failed with the same exception. Then i tried to send the first 100 chars of the image and it worked (the image got corrupted but i received a success, not an exception)
Is there something that has to do with body size or length?
@natebosch are there any news?
I'm not aware of any new limitation on body size. What is the stack trace for the exception?