This commit is contained in:
2021-08-12 15:24:30 +08:00
parent c2109e1760
commit f226c9ba3b
+3 -3
View File
@@ -166,17 +166,17 @@ class Response extends HttpService implements ResponseInterface
* @param bool $isChunk * @param bool $isChunk
* @param int $offset * @param int $offset
* @param int $limit * @param int $limit
* @return FileResponse * @return static
* @throws Exception * @throws Exception
*/ */
public function sendFile(string $path, bool $isChunk = false, int $offset = 0, int $limit = 10240): FileResponse public function sendFile(string $path, bool $isChunk = false, int $offset = 0, int $limit = 10240): static
{ {
$this->format = self::FILE; $this->format = self::FILE;
if (!file_exists($path)) { if (!file_exists($path)) {
throw new Exception('File `' . $path . '` not exists.'); throw new Exception('File `' . $path . '` not exists.');
} }
$this->endData = ['path' => $path, 'isChunk' => $isChunk, 'limit' => $limit, 'offset' => $offset]; $this->endData = ['path' => $path, 'isChunk' => $isChunk, 'limit' => $limit, 'offset' => $offset];
return new FileResponse($this); return $this;
} }