Samuel Georges 5aa351f67c System files should return fully qualified path
- Not sure how this was not fixed sooner, since there is no easy way to obtain a full qualified URL from a system file.
- If a CDN is used this method will return a URL.
- The asset combiner returns a FQ URL as well, although it didn't always, perhaps this is a relic from that time that was never retrofitted.
2017-02-18 12:23:31 +11:00

60 lines
1.3 KiB
PHP

<?php namespace System\Models;
use Url;
use Config;
use October\Rain\Database\Attach\File as FileBase;
/**
* File attachment model
*
* @package october\system
* @author Alexey Bobkov, Samuel Georges
*/
class File extends FileBase
{
/**
* @var string The database table used by the model.
*/
protected $table = 'system_files';
/**
* If working with local storage, determine the absolute local path.
*/
protected function getLocalRootPath()
{
return Config::get('filesystems.disks.local.root', storage_path('app'));
}
/**
* Define the public address for the storage path.
*/
public function getPublicPath()
{
$uploadsPath = Config::get('cms.storage.uploads.path', '/storage/app/uploads');
if ($this->isPublic()) {
$uploadsPath .= '/public';
}
else {
$uploadsPath .= '/protected';
}
return Url::asset($uploadsPath) . '/';
}
/**
* Define the internal storage path.
*/
public function getStorageDirectory()
{
$uploadsFolder = Config::get('cms.storage.uploads.folder');
if ($this->isPublic()) {
return $uploadsFolder . '/public/';
}
else {
return $uploadsFolder . '/protected/';
}
}
}