public static function prepareAttachmentHeaders(
        ResponseInterface $response,
        ?string $filename = null
    ): ResponseInterface {
        $response = $response->withHeader('Content-Type', 'application/octet-stream')
            ->withHeader('Cache-Control', 'no-store, no-cache, must-revalidate')
            ->withHeader('Content-Transfer-Encoding', 'binary')
            ->withHeader('Content-Encoding', 'none');

        if ($filename !== null) {
            $response = $response->withHeader(
                'Content-Disposition',
                'attachment; filename*=utf-8\'\'' . rawurlencode($filename)
            );
        }

        return $response;
    }
public static function prepareAttachmentHeaders(
        ResponseInterface $response,
        ?string $filename = null
    ): ResponseInterface {
        $response = $response->withHeader('Content-Type', 'application/octet-stream')
            ->withHeader('Cache-Control', 'no-store, no-cache, must-revalidate')
            ->withHeader('Content-Transfer-Encoding', 'binary')
            ->withHeader('Content-Encoding', 'none');

        if ($filename !== null) {
            $response = $response->withHeader(
                'Content-Disposition',
                'attachment; filename*=utf-8\'\'' . rawurlencode($filename)
            );
        }

        return $response;
    }
public static function prepareAttachmentHeaders ( ResponseInterface $ response , ? string $ filename = null ) : ResponseInterface { $ response = $ response -> withHeader ( 'Content-Type' , 'application/octet-stream' ) -> withHeader ( 'Cache-Control' , 'no-store, no-cache, must-revalidate' ) -> withHeader ( 'Content-Transfer-Encoding' , 'binary' ) -> withHeader ( 'Content-Encoding' , 'none' ) ; if ( $ filename !== null ) { $ response = $ response -> withHeader ( 'Content-Disposition' , 'attachment; filename*=utf-8\'\'' . rawurlencode ( $ filename ) ) ; } return $ response ; }
Prepare attachment headers to response object.

@param  ResponseInterface $response The response object.
@param  string            $filename Download file name.

@return  ResponseInterface
Prepare attachment headers to response object .