mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 12:33:56 +00:00
Update: laravel 8 to 12, php 7.3 to php 8.3, Jenkinsfile, Unit/Feature testing, vapor, docker
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Classes\ValueObjects\Constants\FileType;
|
||||
use Illuminate\Support\Str;
|
||||
use Intervention\Image\ImageManager;
|
||||
use Intervention\Image\Drivers\Gd\Driver;
|
||||
|
||||
class FileObject implements DataTransferObject
|
||||
{
|
||||
@@ -28,7 +29,13 @@ class FileObject implements DataTransferObject
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return in_array($this->getExtension(), ['pdf', 'excel', 'text']) ? $this->data : (new imageManager())->make($this->data);
|
||||
// intervention/image v2: old
|
||||
//return in_array($this->getExtension(), ['pdf', 'excel', 'text']) ? $this->data : (new imageManager())->make($this->data);
|
||||
|
||||
// intervention/image v3: new
|
||||
return in_array($this->getExtension(), ['pdf', 'excel', 'text'])
|
||||
? $this->data
|
||||
: (new ImageManager(new Driver()))->read($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,7 +60,7 @@ class FileObject implements DataTransferObject
|
||||
*/
|
||||
public function getExtension(): string
|
||||
{
|
||||
if(array_key_exists($this->getMimeType(), FileType::EXTENSION)){
|
||||
if (array_key_exists($this->getMimeType(), FileType::EXTENSION)) {
|
||||
return FileType::EXTENSION[$this->getMimeType()];
|
||||
}
|
||||
|
||||
@@ -66,9 +73,10 @@ class FileObject implements DataTransferObject
|
||||
*/
|
||||
public function getDecodedData(): string
|
||||
{
|
||||
// intervention/image v3: Use encode()->toDataUri() instead of encode('data-url')->encoded
|
||||
return in_array($this->getExtension(), ['pdf', 'excel', 'text']) ?
|
||||
base64_decode((explode('base64,', $this->getData()))[1]):
|
||||
$this->getData()->encode('data-url')->encoded;
|
||||
base64_decode((explode('base64,', $this->getData()))[1]) :
|
||||
$this->getData()->encode()->toDataUri();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user