I am trying to download image stored in Google Cloud Storage Bucket. I am using following code:
$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);
I checked $pathToFile
is good and i am getting a valid filesize.
But I am unable to download file.
I checked App Engine Logs.
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} [] []