#StackBounty: #php #laravel #download #hotlinking Laravel download response with hotlink protection and low memory usage

Bounty: 50

I have a file download website and I serve the files through Laravel for hotlink protection, but it seems like downloads keep my php processes alive for a very long time (as some users have bad download speed).

For hotlink protection I create a session when the user enters the download page and check it when they click the download button.

Is there any way to do the hotlink protection or can I just lower memory usage?

This is the code that triggers the download:

if($request->session()->get('file') == $apk->generated_filename) 
            $headers = array
                'Content-Type' => 'application/vnd.android.package-archive'
            return response()->download(config('custom.storage') . $apk->generated_filename, $apk->filename, $headers);

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.