Laravel Vapor - code sync from shipping portal to solve issue related to AWS S3

This commit is contained in:
Dillon Ngo
2024-05-17 14:49:42 +08:00
parent dec26e53fa
commit 11ba52fbb9
2 changed files with 16 additions and 7 deletions
@@ -14,6 +14,7 @@ use Illuminate\Support\Str;
use Maatwebsite\Excel\Facades\Excel;
use Maatwebsite\Excel\Excel as ExcelFileTypes;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Log;
class ImportUpdateDebtorController
{
@@ -26,16 +27,17 @@ class ImportUpdateDebtorController
$object = new DocumentObject('', $request->input('files'), '', ApprovalStatus::APPROVED, 'imports');
$file = json_decode($object->getFiles()[0])->file_info->original->file;
Log::info('ImportUpdateDebtorController file: ' . $file);
$filesystemDriver = Storage::getDefaultDriver();
if($filesystemDriver === 's3'){
$file = Storage::disk('s3')->path('documents/' . $file);
Excel::import(new ImportsDebtor(), $file, 's3');
}
else{
$file = 'documents/' . $file;
Excel::import(new ImportsDebtor(), $file);
}
//Shipping Portal requires the following (NOT TESTED)
// else{
// $file = 'documents/' . $file;
// }
Excel::import(new ImportsDebtor(), $file);
return [];
}
}