MultipartFile constructor

  1. @Deprecated('MultipartFile.clone() will not work when the stream is provided, use the MultipartFile.fromStream instead.' 'This will be removed in 6.0.0')
MultipartFile(
  1. Stream<List<int>> stream,
  2. int length, {
  3. String? filename,
  4. DioMediaType? contentType,
  5. Map<String, List<String>>? headers,
})

Creates a new MultipartFile from a chunked Stream of bytes. The length of the file in bytes must be known in advance. If it's not, read the data from the stream and use MultipartFile.fromBytes instead.

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

Implementation

@Deprecated(
  'MultipartFile.clone() will not work when the stream is provided, use the MultipartFile.fromStream instead.'
  'This will be removed in 6.0.0',
)
MultipartFile(
  Stream<List<int>> stream,
  this.length, {
  this.filename,
  DioMediaType? contentType,
  Map<String, List<String>>? headers,
})  : _dataBuilder = (() => stream),
      headers = caseInsensitiveKeyMap(headers),
      contentType = contentType ?? MediaType('application', 'octet-stream');