Export pdf file from Laravel Vapor through S3 bucket

This commit is contained in:
Dillon Ngo
2024-06-18 11:38:43 +08:00
parent 38aa670528
commit fcaee29be3
8 changed files with 106 additions and 31 deletions
@@ -41,7 +41,7 @@ class ExportCustomersToExcelController
$exportFileName = 'customers.csv';
$filesystemDriver = Storage::getDefaultDriver();
if($filesystemDriver === 's3'){
return response([ 'src' => AWSS3Helper::S3($exportFileName, $exportsCustomers) ]);
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsCustomers) ]);
}
else{
return $exportsCustomers->download($exportFileName, Excel::CSV, ['Content-Type' => 'text/csv']);
@@ -52,7 +52,7 @@ class ExportCustomersToExcelController
$exportFileName = 'CurrencyVendorOrder.xls';
$filesystemDriver = Storage::getDefaultDriver();
if($filesystemDriver === 's3'){
return response([ 'src' => AWSS3Helper::S3($exportFileName, $exportCurrencyVendorOrder) ]);
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportCurrencyVendorOrder) ]);
}
else{
$response = $exportCurrencyVendorOrder->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
@@ -65,7 +65,7 @@ class ExportCustomersToExcelController
$exportFileName = 'transactions.csv';
$filesystemDriver = Storage::getDefaultDriver();
if($filesystemDriver === 's3'){
return response([ 'src' => AWSS3Helper::S3($exportFileName, $exportsTransactions) ]);
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsTransactions) ]);
}
else{
return $exportsTransactions->download($exportFileName, Excel::CSV, ['Content-Type' => 'text/csv']);
@@ -76,7 +76,7 @@ class ExportCustomersToExcelController
$exportFileName = 'nullDebtor.xls';
$filesystemDriver = Storage::getDefaultDriver();
if($filesystemDriver === 's3'){
return response([ 'src' => AWSS3Helper::S3($exportFileName, $exportsNullDebtors) ]);
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsNullDebtors) ]);
}
else{
$response = $exportsNullDebtors->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
@@ -90,7 +90,7 @@ class ExportCustomersToExcelController
$exportFileName = 'payment-transactions.xls';
$filesystemDriver = Storage::getDefaultDriver();
if($filesystemDriver === 's3'){
return response([ 'src' => AWSS3Helper::S3($exportFileName, $exportsTransactions) ]);
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsTransactions) ]);
}
else{
$response = $exportsTransactions->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
@@ -104,7 +104,7 @@ class ExportCustomersToExcelController
$exportFileName = 'white-form-transactions.xls';
$filesystemDriver = Storage::getDefaultDriver();
if($filesystemDriver === 's3'){
return response([ 'src' => AWSS3Helper::S3($exportFileName, $exportsTransactions) ]);
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsTransactions) ]);
}
else{
$response = $exportsTransactions->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
@@ -118,7 +118,7 @@ class ExportCustomersToExcelController
$exportFileName = 'wallet-transactions.xls';
$filesystemDriver = Storage::getDefaultDriver();
if($filesystemDriver === 's3'){
return response([ 'src' => AWSS3Helper::S3($exportFileName, $exportsTransactions) ]);
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsTransactions) ]);
}
else{
$response = $exportsTransactions->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
@@ -132,7 +132,7 @@ class ExportCustomersToExcelController
$exportFileName = 'invoice-transactions.xls';
$filesystemDriver = Storage::getDefaultDriver();
if($filesystemDriver === 's3'){
return response([ 'src' => AWSS3Helper::S3($exportFileName, $exportsTransactions) ]);
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsTransactions) ]);
}
else{
$response = $exportsTransactions->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
@@ -146,7 +146,7 @@ class ExportCustomersToExcelController
$exportFileName = 'receipt-transactions.xls';
$filesystemDriver = Storage::getDefaultDriver();
if($filesystemDriver === 's3'){
return response([ 'src' => AWSS3Helper::S3($exportFileName, $exportsTransactions) ]);
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsTransactions) ]);
}
else{
$response = $exportsTransactions->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
@@ -159,7 +159,7 @@ class ExportCustomersToExcelController
$exportFileName = 'bookingTransactions.xls';
$filesystemDriver = Storage::getDefaultDriver();
if($filesystemDriver === 's3'){
return response([ 'src' => AWSS3Helper::S3($exportFileName, $exportsBookingTransactions) ]);
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsBookingTransactions) ]);
}
else{
$response = $exportsBookingTransactions->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
@@ -172,7 +172,7 @@ class ExportCustomersToExcelController
$exportFileName = 'leadsData.xls';
$filesystemDriver = Storage::getDefaultDriver();
if($filesystemDriver === 's3'){
return response([ 'src' => AWSS3Helper::S3($exportFileName, $exportsLeadsTransactions) ]);
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsLeadsTransactions) ]);
}
else{
$response = $exportsLeadsTransactions->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
@@ -185,7 +185,7 @@ class ExportCustomersToExcelController
$exportFileName = $request->input('fileName').'.xls';
$filesystemDriver = Storage::getDefaultDriver();
if($filesystemDriver === 's3'){
return response([ 'src' => AWSS3Helper::S3($exportFileName, $exportsImportedInvoiceMappeds) ]);
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsImportedInvoiceMappeds) ]);
}
else{
$response = $exportsImportedInvoiceMappeds->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
@@ -198,7 +198,7 @@ class ExportCustomersToExcelController
$exportFileName = $request->input('fileName').'.xls';
$filesystemDriver = Storage::getDefaultDriver();
if($filesystemDriver === 's3'){
return response([ 'src' => AWSS3Helper::S3($exportFileName, $exportsImportedReceiptMappeds) ]);
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsImportedReceiptMappeds) ]);
}
else{
$response = $exportsImportedReceiptMappeds->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);