multipart property

Stream<MultipartPart> get multipart

PARSES the request body as a multipart stream.

This allows processing large file uploads without loading the entire body into memory. Use MultipartPart.readString for text fields and MultipartPart.stream for files.

Implementation

Stream<MultipartPart> get multipart {
  final contentType = mediaType;
  if (contentType == null ||
      contentType.type != 'multipart' ||
      contentType.subtype != 'form-data') {
    return const Stream.empty();
  }

  final boundary = contentType.parameters['boundary'];
  if (boundary == null) {
    return const Stream.empty();
  }

  return MimeMultipartTransformer(
    boundary,
  ).bind(shelfRequest.read()).map((part) => MultipartPart(part));
}