From c0a87da77a8059d1069f5cf0d1e8e4c1c1b2d31a Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 26 Apr 2024 17:52:03 +0800 Subject: [PATCH] Laravel Vapor - debug reading from S3 storage --- .../ControllersLogic/BulkDownloadCustomerInvoicesLogic.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/Companies/ControllersLogic/BulkDownloadCustomerInvoicesLogic.php b/app/Classes/Modules/Companies/ControllersLogic/BulkDownloadCustomerInvoicesLogic.php index 13f7e710..b6279192 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/BulkDownloadCustomerInvoicesLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/BulkDownloadCustomerInvoicesLogic.php @@ -65,6 +65,8 @@ class BulkDownloadCustomerInvoicesLogic $zipFileName = "invoices_{$startDate}_to_{$endDate}_{$company->reference}.zip"; $zip_file = "{$zipDirectory}/{$zipFileName}"; + $zipFileName2 = "invoices_{$startDate}_to_{$endDate}_{$company->reference}_dup.zip"; + $zip_file2 = "{$zipDirectory}/{$zipFileName2}"; $zip = new ZipArchive(); if ($zip->open($zip_file, ZipArchive::CREATE | ZipArchive::OVERWRITE)) { @@ -79,7 +81,9 @@ class BulkDownloadCustomerInvoicesLogic Storage::put($filePath, file_get_contents($zip_file), 's3'); $responseContent = Storage::disk('s3')->get($filePath); - return response($responseContent)->header('Content-Type', 'application/zip'); + file_put_contents($zip_file2, $responseContent); + + return response()->download($zip_file2); } else { return response()->json([ 'status' => 'Error',