From e4a1836f2387153e34dba69e1353d523d9733c64 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Mon, 17 Jun 2024 11:07:28 +0800 Subject: [PATCH] Export file directly from Laravel Vapor without going through S3 bucket --- .../Controllers/Exports/ExportCustomersToExcelController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php index 63637e82..bfeb2178 100644 --- a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php +++ b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php @@ -66,7 +66,9 @@ class ExportCustomersToExcelController mkdir($exportDirectory, 0755, true); } $localPath = $exportDirectory . '/' . $exportFileName; - $response = $exportsTransactions->store($exportFileName, 'local', Excel::XLS); + $response = $exportsTransactions->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); + + file_put_contents($localPath, $response); return response()->file($localPath, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); } else{