'Send files from flutter web to .net api
I'm trying to send files to .net api, but api response me
{"mensaje":"startIndex cannot be larger than length of string. (Parameter 'startIndex')"}
void _handleResult(Object? result) {
setState(() {
_bytesData = Base64Decoder().convert(result.toString().split(",").last);
_selectedFile = _bytesData;
});
}
Future<String?> makeRequest() async {
var url = Uri.parse("http://*****._____.com.bo:88/serviciosDocumento/api/DocumentosAdicionar");
var request = new http.MultipartRequest("POST", url)..fields['usuIdR'] = "8";
print(_selectedFile);
request.files.add(await http.MultipartFile.fromBytes('request', _selectedFile,
// contentType: new MediaType('application', 'octet-stream'),
filename: "file_up"));
//send
var response = await request.send();
print(response.statusCode);
// listen for response
response.stream.transform(utf8.decoder).listen((value) {
print(value);
});
}
This error not appears when compile in mobile
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|