MultipartFile.fromBytes constructor

MultipartFile.fromBytes(
  1. List<int> value, {
  2. String? filename,
  3. DioMediaType? contentType,
  4. Map<String, List<String>>? headers,
})

Creates a new MultipartFile from a byte array.

contentType currently defaults to application/octet-stream, but in the future may be inferred from filename.

Implementation

factory MultipartFile.fromBytes(
  List<int> value, {
  String? filename,
  DioMediaType? contentType,
  final Map<String, List<String>>? headers,
}) {
  return MultipartFile.fromStream(
    () => Stream.fromIterable([value]),
    value.length,
    filename: filename,
    contentType: contentType,
    headers: headers,
  );
}