jeudi 29 mars 2018

Download Big Protected Files from api! Laravel

I Used download function for download a file in the protected storage folder but when I requested to the server for response a 50 MB file, first the server download it on browser then send it to the user. in other words, I want to user download a file after send request to laravel api! Backend: Laravel Frontend: Angular 4 thanks.

I used these code

$headers = ['Content-Type' => $file->mime,
'Content-Disposition'=>'attachment; filename="' . $file->original_name . 
'"','Access-Control-Expose-Headers' => 'Content-Disposition'];

return response()
    ->download(storage_path("app/{$file->path}"),$file->original_name, 
    $headers);

and it works fine but my problem is when I serving request to download a file with 50 MB size, response time is very long because first, 50 MB files load on browser network tab and nothing show to the user to know about download file.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2E3Aa6o
via IFTTT

Aucun commentaire:

Enregistrer un commentaire