From 78fbd66a53cd4b09dda35d91527bdc685363f036 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Tue, 30 Apr 2024 12:15:16 +0800 Subject: [PATCH 1/2] Laravel Vapor - sync code for download files in bulk from S3 to more files --- app/Classes/General/ExcelHandel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Classes/General/ExcelHandel.php b/app/Classes/General/ExcelHandel.php index 31034ff8..cc476b0d 100644 --- a/app/Classes/General/ExcelHandel.php +++ b/app/Classes/General/ExcelHandel.php @@ -72,13 +72,13 @@ class ExcelHandel if($filesystemDriver === 's3'){ $filePathForS3 = 'public/excels/' . $path . '/' . $filename . '.' . $extension; Storage::disk('s3')->put($filePathForS3, $exceldata); + $file_info['original']['file'] = Storage::disk('s3')->path($filePathForS3); } else{ $file = Storage::disk('public')->put('excels/' . $path . '/' . $filename . '.' . $extension, $exceldata); + $file_info['original']['file'] = storage_path('app/public/excels/' . $path . '/' . $filename . '.' . $extension); } - $file_info['original']['file'] = storage_path('app/public/excels/' . $path . '/' . $filename . '.' . $extension); - return $file_info; } From 608297c77c4b4b72bc3897fe063c5be7afdc7d5d Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Tue, 30 Apr 2024 13:07:25 +0800 Subject: [PATCH 2/2] Laravel Vapor - sync code for download files in bulk from S3 to more files --- .../Imports/ImportUpdateDebtorController.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Imports/ImportUpdateDebtorController.php b/app/Http/Controllers/Imports/ImportUpdateDebtorController.php index b3d5a534..77ed1e92 100644 --- a/app/Http/Controllers/Imports/ImportUpdateDebtorController.php +++ b/app/Http/Controllers/Imports/ImportUpdateDebtorController.php @@ -13,6 +13,7 @@ use Illuminate\Support\Facades\Auth; use Illuminate\Support\Str; use Maatwebsite\Excel\Facades\Excel; use Maatwebsite\Excel\Excel as ExcelFileTypes; +use Illuminate\Support\Facades\Storage; class ImportUpdateDebtorController { @@ -23,7 +24,18 @@ class ImportUpdateDebtorController */ public function import(Request $request) { $object = new DocumentObject('', $request->input('files'), '', ApprovalStatus::APPROVED, 'imports'); - Excel::import(new ImportsDebtor(), json_decode($object->getFiles()[0])->file_info->original->file); + $file = json_decode($object->getFiles()[0])->file_info->original->file; + + $filesystemDriver = Storage::getDefaultDriver(); + if($filesystemDriver === 's3'){ + $file = Storage::disk('s3')->path('documents/' . $file); + } + //Shipping Portal requires the following (NOT TESTED) + // else{ + // $file = 'documents/' . $file; + // } + + Excel::import(new ImportsDebtor(), $file); return []; } }