111
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
|
||||
namespace Http\Message;
|
||||
|
||||
use Server\SInterface\DownloadInterface;
|
||||
use Server\SInterface\OnDownloadInterface;
|
||||
|
||||
|
||||
class Download extends Response implements DownloadInterface
|
||||
class OnDownload extends Response implements OnDownloadInterface
|
||||
{
|
||||
|
||||
use Message;
|
||||
@@ -34,7 +34,7 @@ class Download extends Response implements DownloadInterface
|
||||
* @param int $offset
|
||||
* @return $this
|
||||
*/
|
||||
public function path(string $path, bool $isChunk = false, int $size = -1, int $offset = 0): Download
|
||||
public function path(string $path, bool $isChunk = false, int $size = -1, int $offset = 0): OnDownload
|
||||
{
|
||||
$this->path = $path;
|
||||
$this->isChunk = $isChunk;
|
||||
@@ -6,7 +6,7 @@ use Exception;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Kiri\Core\Help;
|
||||
use Server\Constrict\ResponseInterface;
|
||||
use Server\SInterface\DownloadInterface;
|
||||
use Server\SInterface\OnDownloadInterface;
|
||||
|
||||
|
||||
/**
|
||||
@@ -208,15 +208,15 @@ class Response implements ResponseInterface
|
||||
* @param bool $isChunk
|
||||
* @param int $size
|
||||
* @param int $offset
|
||||
* @return DownloadInterface
|
||||
* @return OnDownloadInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function file($path, bool $isChunk = false, int $size = -1, int $offset = 0): DownloadInterface
|
||||
public function file($path, bool $isChunk = false, int $size = -1, int $offset = 0): OnDownloadInterface
|
||||
{
|
||||
$path = realpath($path);
|
||||
if (!file_exists($path) || !is_readable($path)) {
|
||||
throw new Exception('Cannot read file "' . $path . '", no permission');
|
||||
}
|
||||
return (new Download())->path($path, $isChunk, $size, $offset);
|
||||
return (new OnDownload())->path($path, $isChunk, $size, $offset);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user