can not specify the content type of MultiPartFile in Flutter
I figured out the answer and it is that I must import http parser package
you need to import:
import 'package:http_parser/http_parser.dart';
Just check out this if it works
uploadFile() async {
var postUri = Uri.parse("<APIUrl>");
var request = new http.MultipartRequest("POST", postUri);
request.fields['user'] = 'blah';
request.files.add(new http.MultipartFile.fromBytes('file', await File.fromUri("<path/to/file").readAsBytes(), contentType: new MediaType('image', 'jpeg')))
request.send().then((response) {
if (response.statusCode == 200) print("Uploaded!");
});
}