Return a file as a response

def file(self, path, status=200, set_content_length=True):
        """
        Return a file as a response
        """
        ct, encoding = mimetypes.guess_type(path)
        if not ct:
            ct = 'application/octet-stream'
        if encoding:
            self.headers[aiohttp.hdrs.CONTENT_ENCODING] = encoding
        self.content_type = ct

        if set_content_length:
            st = os.stat(path)
            self.last_modified = st.st_mtime
            self.headers[aiohttp.hdrs.CONTENT_LENGTH] = str(st.st_size)
        else:
            self.enable_chunked_encoding()

        self.set_status(status)

        try:
            with open(path, 'rb') as fobj:
                yield from self.prepare(self._request)

                while True:
                    data = fobj.read(4096)
                    if not data:
                        break
                    yield from self.write(data)
                    yield from self.drain()

        except FileNotFoundError:
            raise aiohttp.web.HTTPNotFound()
        except PermissionError:
            raise aiohttp.web.HTTPForbidden()