19 public function url($alias){
20 return $this->
component(
'router')->reverse($this->controllerName,\
Rsi\File::ext($this->files[$alias]),[
'alias' => $alias]);
27 public function alias($filename){
29 array_key_exists($alias = preg_replace(
'/\\.\w*$/',
'',basename($filename)),$this->files) &&
30 ($this->files[$alias] != $filename)
31 ) $alias = md5($filename) .
'-' . $alias;
40 public function add($filename,$alias = null){
41 if(!$alias) $alias = $this->
alias($filename);
42 $this->session->files = $this->_files = [$alias => $filename] + $this->files;
43 return $this->
url($alias);
50 if(!array_key_exists($alias,$this->files)) $this->_fred->externalError(
"Invalid proxy alias '$alias'");
51 header(
'Content-Type: ' . \
Rsi\File::mime($filename = $this->files[$alias]));
57 if($this->_files === null) $this->_files = $this->session->files ?: $this->
config(
'files',[]);
alias($filename)
Create a unique alias for a filename.
config($key, $default=null)
Retrieve a config value.
add($filename, $alias=null)
Add a file to the list.
url($alias)
Create a URL for an alias.
Proxy for files that are outside of the public document root.
serve($alias)
Serve a file.
component($name)
Get a component (local or default).
$controllerName
Controller for the proxy. Has param 'alias'.