radarrplexorganizrnginxsonarrdashboardserverhomepagesabnzbdheimdallembycouchpotatonzbgetbookmarkapplication-dashboardmuximuxlandingpagestartpagelandinghtpc
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.1 KiB
62 lines
1.1 KiB
<?php
|
|
|
|
namespace Illuminate\Http;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
trait FileHelpers
|
|
{
|
|
/**
|
|
* The cache copy of the file's hash name.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $hashName = null;
|
|
|
|
/**
|
|
* Get the fully qualified path to the file.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function path()
|
|
{
|
|
return $this->getRealPath();
|
|
}
|
|
|
|
/**
|
|
* Get the file's extension.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function extension()
|
|
{
|
|
return $this->guessExtension();
|
|
}
|
|
|
|
/**
|
|
* Get the file's extension supplied by the client.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function clientExtension()
|
|
{
|
|
return $this->guessClientExtension();
|
|
}
|
|
|
|
/**
|
|
* Get a filename for the file.
|
|
*
|
|
* @param string $path
|
|
* @return string
|
|
*/
|
|
public function hashName($path = null)
|
|
{
|
|
if ($path) {
|
|
$path = rtrim($path, '/').'/';
|
|
}
|
|
|
|
$hash = $this->hashName ?: $this->hashName = Str::random(40);
|
|
|
|
return $path.$hash.'.'.$this->guessExtension();
|
|
}
|
|
}
|
|
|