改名
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Server\Constrict;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use HttpServer\Http\Formatter\FileFormatter;
|
use HttpServer\Http\Formatter\FileFormatter;
|
||||||
use Server\ResponseInterface;
|
use Server\ResponseInterface;
|
||||||
|
use validator\EnumValidator;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,12 +48,21 @@ class ResponseEmitter
|
|||||||
// $response->header('Content-Type', 'application/download');
|
// $response->header('Content-Type', 'application/download');
|
||||||
$response->header('Content-Disposition', 'attachment;filename=' . end($explode));
|
$response->header('Content-Disposition', 'attachment;filename=' . end($explode));
|
||||||
$response->header('Content-Transfer-Encoding', 'binary');
|
$response->header('Content-Transfer-Encoding', 'binary');
|
||||||
$response->setStatusCode(200);
|
|
||||||
if ($content['isChunk'] === false) {
|
if ($content['isChunk'] === false) {
|
||||||
$response->sendfile($content['path']);
|
$response->sendfile($content['path']);
|
||||||
return;
|
} else {
|
||||||
|
$this->chunk($content, $response);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $content
|
||||||
|
* @param $response
|
||||||
|
*/
|
||||||
|
private function chunk($content, $response): void
|
||||||
|
{
|
||||||
$resource = fopen($content['path'], 'r');
|
$resource = fopen($content['path'], 'r');
|
||||||
|
|
||||||
$state = fstat($resource);
|
$state = fstat($resource);
|
||||||
|
|||||||
Reference in New Issue
Block a user