Want to upload file using POST request in flutter? The correct way is to use a MultipartRequest:
1 2 3 4 5 6 7 8 9 10 | var uri = Uri.parse(url); var request = new MultipartRequest("POST", uri); var multipartFile = await MultipartFile.fromPath("package", videoPath); request.files.add(multipartFile); StreamedResponse response = await request.send(); response.stream.transform(utf8.decoder).listen((value) { print(value); }); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.