cakephp下载大文件,标题内容长度缺失

时间:2018-05-11 16:07:37

标签: php apache cakephp-3.0

我在CakePHP 3.6中有以下代码下载文件:

public function download($id){
   $movie = $this->Movies->get($id)->toArray();
   $myfile = new File($movie['path'] . $movie['filename']);
   return $this->response->withFile($myfile->path, ['download' => true]);
}

在浏览器中,它有以下标题:

accept-ranges:bytes
cache-control:no-store, no-cache, must-revalidate
content-disposition:attachment; filename="Film.avi"
content-encoding: gzip
content-transfer-encoding:binary
content-type:video/x-msvideo
date:Fri, 11 May 2018 15:43:47 GMT
expires:Thu, 19 Nov 1981 08:52:00 GMT
pragma:no-cache
server:nginx
strict-transport-security:max-age=15768000
vary:Accept-Encoding
X-Firefox-Spdy:h2

我需要在下载时看到进度%,这意味着缺少Content-length标头。当我添加到功能:

$s = $myfile->size();
$this->response->withFile($myfile->path, ['download']->true])->withHeader('Content-Length',$s);

仍然没有成功。你能帮我吗 ?我错过了一整天。 用qzip做的东西。我发现它应该被禁用但我不知道如何......

0 个答案:

没有答案