From cf80e31df73da92c53d087a0f3d13934d76cc2d3 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 27 Apr 2024 13:05:41 +0800 Subject: [PATCH] Laravel Vapor - sync code for download files in bulk from S3 to more files --- .../BulkDownloadSupplierWhiteFormsLogic.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/Companies/ControllersLogic/BulkDownloadSupplierWhiteFormsLogic.php b/app/Classes/Modules/Companies/ControllersLogic/BulkDownloadSupplierWhiteFormsLogic.php index 00b19b79..718aaa1a 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/BulkDownloadSupplierWhiteFormsLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/BulkDownloadSupplierWhiteFormsLogic.php @@ -49,6 +49,8 @@ class BulkDownloadSupplierWhiteFormsLogic $endDate = $endDate->format('d-m-Y'); $zipFileName = "currency_vendor_orders_{$startDate}_to_{$endDate}_{$companyReference}.zip"; $zip_file = "{$zipDirectory}/{$zipFileName}"; + $zipFileName2 = "currency_vendor_orders_{$startDate}_to_{$endDate}_{$companyReference}_dup.zip"; + $zip_file2 = "{$zipDirectory}/{$zipFileName2}"; $zip = new ZipArchive(); if ($zip->open($zip_file, ZIPARCHIVE::CREATE | ZipArchive::OVERWRITE)) { @@ -69,9 +71,13 @@ class BulkDownloadSupplierWhiteFormsLogic $filePathForS3 = 'bulk_whiteform/'.$zipFileName; Storage::put($filePathForS3, file_get_contents($zip_file), 's3'); + + $responseContent = Storage::disk('s3')->get($filePathForS3); + file_put_contents($zip_file2, $responseContent); + Log::info('BulkDownloadSupplierWhiteFormsLogic finished processing files count: '.count($groups)); - return response()->download($zip_file); + return response()->download($zip_file2); } else { return response()->json([