Download files from storage in Laravel

2450
Download files from storage in Laravel

A filesystem is often an underrated but very important factor in web development. Downloading files from storage in laravel application is even easier with the implementation of response or download method. This feature was added by reinink and merged by taylor in laravel 5.5.

“The download method accepts a file name as the second argument to the method, which will determine the file name that is seen by the user downloading the file. Finally, you may pass an array of HTTP headers as the third argument to the method” as described in the documents.

Example:

/**
 * Automatically return a file from any filesystem as an HTTP response
 * You can optionally set a filename, headers, and disposition
 * @param  User   $user [description]
 * @return [type]       [description]
 */
public function photo(User $user)
{
    return Storage::response($user->photo);
}

/**
 * You can also use the download() method to force download a file
 * @param  User   $user [description]
 * @return [type]       [description]
 */
public function resume(User $user)
{
    return Storage::download($user->resume, 'resume.pdf');
}

4 COMMENTS

  1. Amoxicillin Causing Sickness Zesiulge https://ascialis.com/# – Cialis cooleascepsy Cialis Viagra Generico expeni Cialis rawlrelayday Ajanta Pharma Kamagra

  2. What Is Amoxicillin Bp ruicky https://acialisse.com/ – Cialis Maiveambitte Cephalexin Keflex 500 Mg acalyholenna buying cialis online roobbyiker Levitra Generique

  3. Cialis Einnahmezeitpunkt Zesiulge https://cialisse.com/ – cheapest cialis online cooleascepsy Non Prescription Tretinoin Cream expeni buy cialis 5mg daily use rawlrelayday Will Propecia Work Forever Thinning Hair

  4. acheter cialis en pharmacie en france Zesiulge https://cialisse.com/ – Cialis cooleascepsy Cephalexin Nursing Responsibilities expeni Cialis rawlrelayday Levitra Pastiglie

LEAVE A REPLY

Please enter your comment!
Please enter your name here