Laravel Vapor - sync code for download files in bulk from S3 to more files

This commit is contained in:
Dillon Ngo
2024-04-27 13:05:41 +08:00
parent e97515ab9f
commit cf80e31df7
@@ -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([