mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-21 21:43:57 +00:00
Export file directly from Laravel Vapor without going through S3 bucket
This commit is contained in:
@@ -58,9 +58,19 @@ class ExportCustomersToExcelController
|
||||
|
||||
public function paymentTransactions(Request $request){
|
||||
$exportsTransactions = new ExportsPaymentTransactions($request);
|
||||
$response = $exportsTransactions->download('payment-transactions.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
$exportFileName = 'payment-transactions.xls';
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver !== 's3'){
|
||||
if($filesystemDriver === 's3'){
|
||||
$exportDirectory = storage_path('app/export'); // Update this with the actual directory path
|
||||
if (!file_exists($exportDirectory)) {
|
||||
mkdir($exportDirectory, 0755, true);
|
||||
}
|
||||
$localPath = $exportDirectory . '/' . $exportFileName;
|
||||
$response = $exportsTransactions->store($localPath, null, Excel::XLS);
|
||||
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']);
|
||||
ob_end_clean();
|
||||
}
|
||||
return $response;
|
||||
@@ -118,3 +128,4 @@ class ExportCustomersToExcelController
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user