toMultipartFile method

Future<MultipartFile?> toMultipartFile()

Convert HttpFile to MultipartFile.

A file to be uploaded as part of a MultipartRequest. This doesn't need to correspond to a physical file.

Implementation

Future<MultipartFile?> toMultipartFile() async {
  if (bytes != null) {
    return MultipartFile.fromBytes(field, bytes!,
        filename: filename, contentType: contentType);
  } else if (filePath != null) {
    return MultipartFile.fromPath(field, filePath!,
        filename: filename, contentType: contentType);
  } else if (value != null) {
    return MultipartFile.fromString(field, value!,
        filename: filename, contentType: contentType);
  }
  return null;
}