Guzzle get file and forward it
public function streamAction(){ $response = $client->request( 'GET', 'http://httpbin.org/stream-bytes/1024', ['stream' => true] ); $body = $response->getBody(); $response = new StreamedResponse(function() use ($body) { while (!$body->eof()) { echo $body->read(1024); } }); $response->headers->set('Content-Type', 'text/xml'); return $response;}
$response = $client->request('GET', 'http://example.com/file', ['stream' => true]); $stream = $response->getBody(); $content = new StreamedResponse(function () use ($stream) { /** @var StreamInterface $stream */ while ($binary = $stream->read(1024)) { echo $binary; ob_flush(); flush(); } }, $response->getStatusCode(), [ 'Content-Type' => $response->getHeaderLine('Content-Type'), 'Content-Length' => $response->getHeaderLine('Content-Length'), 'Content-Disposition' => $response->getHeaderLine('Content-Disposition') ]); return $this->renderResponse($content->send());