Skip to content

Instantly share code, notes, and snippets.

@anandiamy
Created July 2, 2019 01:09
Show Gist options
  • Save anandiamy/24423febefaaf821d12b71e2d0d1b3f1 to your computer and use it in GitHub Desktop.
Save anandiamy/24423febefaaf821d12b71e2d0d1b3f1 to your computer and use it in GitHub Desktop.
MinioUrlGenerator
<?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