From c4edcdf814cc6ce23eeab9265ebde7285add8c28 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Mon, 17 Jun 2024 11:26:16 +0800 Subject: [PATCH] Export file directly from Laravel Vapor without going through S3 bucket --- .../Exports/ExportCustomersToExcelController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php index bfeb2178..e3a1926c 100644 --- a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php +++ b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php @@ -65,11 +65,11 @@ class ExportCustomersToExcelController if (!file_exists($exportDirectory)) { mkdir($exportDirectory, 0755, true); } - $localPath = $exportDirectory . '/' . $exportFileName; + // $localPath = $exportDirectory . '/' . $exportFileName; $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']); + // file_put_contents($localPath, $response); + return response()->file($response->getFile()->getPathname(), ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); } else{ $response = $exportsTransactions->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);