Merge branch 'dillon/34.4-jenkins-vapor' into vapor/development

This commit is contained in:
Dillon Ngo
2024-06-17 11:57:42 +08:00
@@ -61,15 +61,22 @@ class ExportCustomersToExcelController
$exportFileName = 'payment-transactions.xls';
$filesystemDriver = Storage::getDefaultDriver();
if($filesystemDriver === 's3'){
$exportDirectory = storage_path('app/export'); // Update this with the actual directory path
//Step 1: Upload to S3
$filePathForS3 = 'temp/' . $exportFileName;
$exportsTransactions->store($filePathForS3, 's3');
//Step 2: Read and Download from S3
$fileContent = Storage::disk('s3')->get($filePathForS3);
$exportDirectory = storage_path('app/temp'); // Update this with the actual directory path
if (!file_exists($exportDirectory)) {
mkdir($exportDirectory, 0755, true);
}
// $localPath = $exportDirectory . '/' . $exportFileName;
$response = $exportsTransactions->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
$localPath = $exportDirectory . '/' . $exportFileName;
file_put_contents($localPath, $fileContent);
// file_put_contents($localPath, $response);
return response()->file($response->getFile()->getPathname(), ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
//Step 3: Return
return response()->file($localPath, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
}
else{
$response = $exportsTransactions->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);