asMultipartPart method

Future<MultipartPart> asMultipartPart({
  1. required String name,
  2. String? filename,
  3. String contentType = 'application/octet-stream',
})

Creates a one-shot streaming part. Do not modify the file during upload. One-shot semantics prevent automatic retries of a changing file.

Implementation

Future<MultipartPart> asMultipartPart(
    {required String name,
    String? filename,
    String contentType = 'application/octet-stream'}) async {
  final size = await length();
  return MultipartPart(
      name: name,
      filename: filename ?? uri.pathSegments.last,
      body: StreamRequestBody(openRead(),
          contentLength: size, contentType: contentType));
}