for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Spatie\MediaLibrary\UrlGenerator;
use DateTimeInterface;
use Illuminate\Filesystem\FilesystemManager;
use Illuminate\Contracts\Config\Repository as Config;
class S3UrlGenerator extends BaseUrlGenerator
{
/** @var \Illuminate\Filesystem\FilesystemManager */
protected $filesystemManager;
public function __construct(Config $config, FilesystemManager $filesystemManager)
$this->filesystemManager = $filesystemManager;
parent::__construct($config);
}
/**
* Get the url for the profile of a media item.
*
* @return string
*/
public function getUrl(): string
return config('medialibrary.s3.domain').'/'.$this->getPathRelativeToRoot();
* Get the temporary url for the profile of a media item.
* @param \DateTimeInterface $expiration
* @param array $options
public function getTemporaryUrl(DateTimeInterface $expiration, array $options = []): string
return $this
->filesystemManager
->disk($this->media->getDiskDriverName())
->temporaryUrl($this->getPath(), $expiration, $options);
public function getPath(): string
return $this->getPathRelativeToRoot();