public function attachment(
        $filename,
        string $name = '',
        string $mime = 'application/octet-stream'
    ): ResponseInterface {
        if (empty($name)) {
            if (!is_string($filename)) {
                throw new ResponseException("Unable to resolve public filename");
            }

            $name = basename($filename);
        }

        $stream = $this->getStream($filename);

        $response = $this->responseFactory->createResponse();
        $response = $response->withHeader('Content-Type', $mime);
        $response = $response->withHeader('Content-Length', (string)$stream->getSize());
        $response = $response->withHeader(
            'Content-Disposition',
            'attachment; filename="' . addcslashes($name, '"') . '"'
        );

        return $response->withBody($stream);
    }