renderFile method

void renderFile(
  1. File file
)

Renders a file by streaming its content to the response.

The file parameter is the File object to render.

Implementation

void renderFile(File file) {
  var fileStream = file.openRead();

  rq.response.headers
      .set('Content-type', lookupMimeType(file.path).toString());
  rq.response.addStream(fileStream).then((value) async {
    await rq.writeAndClose('');
  });
}