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

This commit is contained in:
Dillon Ngo
2024-04-29 11:13:39 +08:00
parent ac214d45b2
commit 29300ee039
@@ -49,8 +49,6 @@ 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)) {
@@ -74,13 +72,13 @@ class BulkDownloadSupplierWhiteFormsLogic
Log::info('BulkDownloadSupplierWhiteFormsLogic finished processing files count: '.count($groups));
return redirect(Storage::disk('s3')->temporaryUrl(
$filePathForS3,
now()->addHour(),
['ResponseContentDisposition' => 'attachment']
));
// return response()->download($url);
return response()->streamDownload(function () use ($filePathForS3) {
return Storage::disk('s3')->temporaryUrl(
$filePathForS3,
Carbon::now()->addMinutes(60),
['ResponseContentDisposition' => 'attachment']
);
}, $zipFileName);
}
else {
return response()->json([