mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Laravel Vapor - code sync from shipping portal to solve issue related to AWS S3
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Classes\General;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ExcelHandel
|
||||
{
|
||||
@@ -72,7 +73,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);
|
||||
|
||||
$temporaryUrl = Storage::disk('s3')->temporaryUrl(
|
||||
$filePathForS3,
|
||||
Carbon::now()->addMinutes(10)
|
||||
);
|
||||
|
||||
$file_info['original']['file'] = $temporaryUrl; //REMINDER: This is a path to AWS S3 URL (HTTPS) as a public anonymous user, NOT an internal system path
|
||||
}
|
||||
else{
|
||||
$file = Storage::disk('public')->put('excels/' . $path . '/' . $filename . '.' . $extension, $exceldata);
|
||||
|
||||
@@ -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 [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user