public function sendContentAsFile($content, $attachmentName, $options = [])
    {
        $contentLength = StringHelper::byteLength($content);
        $range = $this->getHttpRange($contentLength);

        if ($range === false) {
            $this->setHeader('Content-Range', "bytes */$contentLength");
            throw new RangeNotSatisfiableHttpException();
        }

        [$begin, $end] = $range;
        $body = new MemoryStream();
        if ($begin != 0 || $end != $contentLength - 1) {
            $this->setStatusCode(206);
            $this->setHeader('Content-Range', "bytes $begin-$end/$contentLength");
            $body->write(StringHelper::byteSubstr($content, $begin, $end - $begin + 1));
        } else {
            $this->setStatusCode(200);
            $body->write($content);
        }

        $mimeType = $options['mimeType'] ?? 'application/octet-stream';
        $this->setDownloadHeaders($attachmentName, $mimeType, !empty($options['inline']), $end - $begin + 1);

        $this->format = self::FORMAT_RAW;
        $this->setBody($body);
        return $this;
    }