public function sendDownload ($filename, $forceDownload = true)
    {
        if (headers_sent())
        {
            throw new \RuntimeException("Cannot send file to the browser, since the headers were already sent.");
        }

        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: private", false);
        header("Content-Type: {$this->getMimeType($filename)}");

        if ($forceDownload)
        {
            header("Content-Disposition: attachment; filename=\"{$filename}\";" );
        }
        else
        {
            header("Content-Disposition: filename=\"{$filename}\";" );
        }

        header("Content-Transfer-Encoding: binary");
        header("Content-Length: {$this->getFileSize()}");

        @ob_clean();

        rewind($this->filePointer);
        fpassthru($this->filePointer);
    }