Laravel Vapor - Fix path to upload documents to S3 bucket with dynamic path

This commit is contained in:
Dillon Ngo
2023-12-28 23:26:53 +08:00
parent aa319fadc9
commit 0f61a84fc5
3 changed files with 33 additions and 22 deletions
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Documents\DataTransferObjects;
use App\Classes\General\Interfaces\DataTransferObject;
use App\Classes\Modules\Documents\Services\ConvertsBase64ToFile;
use Illuminate\Support\Facades\Storage;
class DocumentObject implements DataTransferObject
{
@@ -72,9 +73,14 @@ class DocumentObject implements DataTransferObject
*/
public function getFiles(): array
{
return (new ConvertsBase64ToFile($this->path))->convert($this->files);
$filePath = $this->path;
$filesystemDriver = Storage::getDefaultDriver();
if($filesystemDriver == 's3'){
$filePath = 'documents/'.$this->path;
}
return (new ConvertsBase64ToFile($filePath))->convert($this->files);
}
}
}