getHttpMutipartFile method

Future<MultipartFile>? getHttpMutipartFile({
  1. required String field,
  2. required File file,
})

This method user to get http multipart request file

Implementation

Future<http.MultipartFile>? getHttpMutipartFile(
    {required String field, required File file}) async {
  String? mimeType = mime(file.absolute.path);
  String mimee = mimeType!.split('/')[0];
  String type = mimeType.split('/')[1];
  print("MIME TYPE ${mimeType}  , ${mimee}, ${type} ");

  var pic = http.MultipartFile.fromBytes('picture', file.readAsBytesSync(),
      filename: file.path.split("/").last,
      contentType: httparser.MediaType(mimee, type));
  return pic;
}