mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-31 18:34:10 +00:00
Merge branch 'dillon/34.4-jenkins-vapor' into vapor/development
This commit is contained in:
@@ -22,6 +22,7 @@ use App\Classes\Modules\Exports\Services\ExportsReceiptTransactions;
|
||||
use App\Classes\Modules\Exports\Services\ExportsImportedReceiptMappeds;
|
||||
use App\Classes\Modules\Exports\Services\ExportsWhiteFormTransactions;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ExportCustomersToExcelController
|
||||
{
|
||||
@@ -61,31 +62,17 @@ class ExportCustomersToExcelController
|
||||
$exportFileName = 'payment-transactions.xls';
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
|
||||
//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;
|
||||
// file_put_contents($localPath, $fileContent);
|
||||
//Step 2: Return temporary URL from S3
|
||||
$temporaryUrl = Storage::disk('s3')->temporaryUrl(
|
||||
$filePathForS3,
|
||||
Carbon::now()->addMinutes(10)
|
||||
);
|
||||
|
||||
// //Step 3: Return
|
||||
// return response()->file($localPath, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
|
||||
$headers = [
|
||||
'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'Content-Disposition' => 'attachment; filename="' . $exportFileName . '"',
|
||||
];
|
||||
|
||||
// Return the file content as a response with the headers
|
||||
return response($fileContent, 200)
|
||||
->withHeaders($headers);
|
||||
return response([ 'src' => $temporaryUrl ]);
|
||||
}
|
||||
else{
|
||||
$response = $exportsTransactions->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
|
||||
Reference in New Issue
Block a user