Created
July 2, 2019 01:09
-
-
Save anandiamy/24423febefaaf821d12b71e2d0d1b3f1 to your computer and use it in GitHub Desktop.
MinioUrlGenerator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Services; | |
use Spatie\MediaLibrary\UrlGenerator\S3UrlGenerator; | |
class MinioUrlGenerator extends S3UrlGenerator | |
{ | |
/** | |
* Get the url for a media item. | |
* | |
* @return string | |
*/ | |
public function getUrl(): string | |
{ | |
$url = $this->getPathRelativeToRoot(); | |
$url = $this->rawUrlEncodeFilename($url); | |
$endpoint = config('filesystems.disks.'.$this->media->disk.'.endpoint'); | |
$bucket = config('filesystems.disks.'.$this->media->disk.'.bucket'); | |
return "$endpoint/$bucket/$url"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment