我正在尝试下载存储在Google云端存储分区中的图像。我使用以下代码:
$headers = array(
'Content-Type'=> 'image/jpeg',
'Content-Disposition' => 'attachment; filename=test.jpg',
'Expires' => '0',
'Content-Length' => filesize($pathToFile),
'Content-Transfer-Encoding' => 'binary',
'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',
);
return Response::download($pathToFile, 'test.jpg', $headers);
我检查$pathToFile
是好的,我正在获得有效的文件大小。
但我无法下载文件。
我检查了App Engine日志。
appengine.ERROR: exception 'ErrorException' with message
'fopen(php://output): failed to open stream: Unknown stream type
php://output.' in
/base/data/home/apps/s~red-flamingo/1.377568004893744378/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php:254
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleError(2, 'fopen(php://out...', '/base/data/home...', 254, Array)
#1 /base/data/home/apps/s~red-flamingo/1.377568004893744378/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php(254):
fopen('php://output', 'wb')
#2/base/data/home/apps/s~red-flamingo/1.377568004893744378/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php(374):
Symfony\Component\HttpFoundation\BinaryFileResponse->sendContent()
#3/base/data/home/apps/s~red-flamingo/1.377568004893744378/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(608):
Symfony\Component\HttpFoundation\Response->send()
#4 /base/data/home/apps/s~red-flamingo/1.377568004893744378/public/index.php(49):
Illuminate\Foundation\Application->run() #5 {main} [] []
答案 0 :(得分:1)
php://输出(请参阅https://code.google.com/p/googleappengine/issues/detail?id=10298)。请改用print或echo。