StreamResponse.fromFile constructor

StreamResponse.fromFile(
  1. File file, {
  2. dynamic statusCode = 200,
  3. Map<String, dynamic>? headers,
  4. String? mimeType,
  5. String? charset,
  6. List<Cookie>? cookies,
})

Response that writes the contents of file to the response.

Implementation

factory StreamResponse.fromFile(
  File file, {
  statusCode = 200,
  Map<String, dynamic>? headers,
  String? mimeType,
  String? charset,
  List<Cookie>? cookies,
}) =>
    StreamResponse(
      body: file.openRead(),
      statusCode: statusCode,
      headers: headers,
      mimeType: mimeType ?? MimeTypes.ofFile(file),
      charset: charset,
      cookies: cookies,
    );