dcat-admin icon indicating copy to clipboard operation
dcat-admin copied to clipboard

Error: Call to undefined method Symfony\Component\HttpFoundation\BinaryFileResponse::header() in file vendor\dcat\laravel-admin\src\Http\Middleware\Pjax.php on line 72

Open sprklinginfo opened this issue 3 years ago • 1 comments

Laravel Version: 8.73.1 PHP Version: 7.4.16 Dcat Admin Version: 2.1.5-beta

Description:

On one of the pages I have download links to non-image files like .txt, the HTML code like this:

<a href="https://my.website/admin/storage/projects/2/192309637test2.txt" class="attchment-link inline-block pr-2" onclick="return(true);">
            <i class="fa fa-paperclip"></i>&nbsp;
            <span class="text-primary">192309637test2.txt</span>
        </a>

When clicking the link, I can download and save the file, but the following error is displayed in the console:

GET https://my.website/admin/storage/projects/2/192309637test2.txt?_pjax=%23pjax-container 500 (Internal Server Error) Call to undefined method Symfony\Component\HttpFoundation\BinaryFileResponse::header() in file vendor\dcat\laravel-admin\src\Http\Middleware\Pjax.php on line 72

checked the code on line 72:

 $response->header(
            'X-PJAX-URL',
            $request->getRequestUri()
        );

According to google search, the code should be changed to:

$response->headers->set($key, $value);

Steps To Reproduce:

sprklinginfo avatar Dec 22 '21 21:12 sprklinginfo

The same problem.

when use response()->download($path) can trigger. In the download function the response is instance of BinaryFileResponse.

cisiqo avatar Mar 06 '22 07:03 cisiqo

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 03 '22 01:09 stale[bot]