0

I have a button that creates and csv , i want it to a return a trigger to download the file to the user. currently i'm getting the file content as the response data. in my controller i use:

Storage::put($filepath, $fileconent);
$headers = [
      'Content-Type' => 'Content-Type: text/csv',
 ];
return Storage::download($filepath, $filename, $headers ); 

(Storage::download adds the 'Content-Disposition: attachment; filename=filename' header)

what am i missing? thanks

Kamlesh Paul
  • 11,778
  • 2
  • 20
  • 33
Ronif
  • 13
  • 2

1 Answers1

0

Try This

  $file =  Storage::disk('s3')->get($file_path);

  $headers = [
    'Content-Type' => 'your_content_type', 
    'Content-Description' => 'File Transfer',
    'Content-Disposition' => "attachment; filename={$yourFileName}",
    'filename'=> $yourFileName
 ];

return response($file, 200, $headers);
Jaynil Savani
  • 310
  • 2
  • 9