readBytes method
Collects the part into memory.
Fine for a form field, and the thing streaming exists to avoid for a file.
limit bounds it anyway, because "this one is small" is a claim the client
is making.
Implementation
Future<Uint8List> readBytes({int limit = defaultBodyLimit}) async {
final builder = BytesBuilder(copy: false);
await for (final chunk in content) {
builder.add(chunk);
if (builder.length > limit) {
throw Rejection.payloadTooLarge(
'multipart part "$name" exceeds $limit bytes',
);
}
}
return builder.takeBytes();
}