Example data from the Postman:
I will get this error after I send a request.
Unhandled exception:
FormatException: Unexpected extension byte (at offset 435)
If I don't send image 1
, I got this.
jsonString:
----------------------------166099235909119466948633
Content-Disposition: form-data; name="key 1"
Content-Type: application/json
value 1
----------------------------166099235909119466948633
Content-Disposition: form-data; name="key 2"
value 2
----------------------------166099235909119466948633--
This can't use JSON decode.
My code:
Future main(List<String> arguments) async {
HttpServer server = await HttpServer.bind('localhost', 8085);
server.listen((HttpRequest request) async {
String jsonString = await request.cast<List<int>>().transform(utf8.decoder).join();
print("jsonString:\n$jsonString");
await request.response.close();
});
}
CodePudding user response:
This solution work with http.MultipartRequest()
from the Flutter app.