fromPath static method
Response that writes the contents of file at path
to the response.
Implementation
static Future<StreamResponse> fromPath(
String path, {
int statusCode = 200,
Map<String, dynamic>? headers,
String? mimeType,
String? charset,
List<Cookie>? cookies,
}) async {
final file = File(path);
if (!await file.exists()) throw new Exception();
return StreamResponse.fromFile(
file,
statusCode: statusCode,
headers: headers,
mimeType: mimeType ?? MimeTypes.ofFile(file),
charset: charset,
cookies: cookies,
);
}