Reputation: 8509
I am using this package to export my collections to excel (CSV):
I use the following code to store it on s3:
$path = Carbon::now()->toDateString() . '/' . bin2hex(random_bytes(32)) . '.csv';
(new BillsExport($bills))->store($path, 's3', \Maatwebsite\Excel\Excel::CSV);
Now for the filename I'm using a random 32 length guid. However when they download the file I want the actual name of the file to be displayed like bills.csv
instead of 4f68481f5a8c09b7823c042d7d2fca457e297839d31e33fcefd09056f86cce00.csv
I would like to know if that is possible and how I can achieve this with laravel using S3 bucket.
Upvotes: 1
Views: 684
Reputation: 8750
You could do that with response()->download()
. For example:
return response()->download($path, 'bills.csv', $headers);
For more information, read the documentation on HTTP Responses.
Upvotes: 1