public function getResponse($id, $filename = null, $forceDownload = false)
	{
		$object = $this->container->get($id);

		if ($filename === null)
		{
			$filename = $object->getBasename();
		}

		if (!pathinfo($filename, PATHINFO_EXTENSION) && $object->getExtension())
		{
			$filename .= '.'. $object->getExtension();
		}

		/** @var HttpResponse $response */
		$response = $this->controller->getResponse();

		$response->setContent(new LazyResponse($object));
		$response->getHeaders()->addHeaders(array(
			'Content-Type' => $object->getContentType() ?: 'application/octet-stream',
			'Content-Disposition' => ($forceDownload ? 'attachment' : 'inline') .';filename="'. str_replace('"', '\\"', $filename) .'"',
			'Content-Transfer-Encoding' => 'binary',
			'Expires' => '-1 year',
			'Cache-Control' => 'must-revalidate',
			'Pragma' => 'public',
			'Content-Length' => $object->getContentLength(),
		));

		return $response;
	}
public function getResponse($id, $filename = null, $forceDownload = false)
	{
		$object = $this->container->get($id);

		if ($filename === null)
		{
			$filename = $object->getBasename();
		}

		if (!pathinfo($filename, PATHINFO_EXTENSION) && $object->getExtension())
		{
			$filename .= '.'. $object->getExtension();
		}

		/** @var HttpResponse $response */
		$response = $this->controller->getResponse();

		$response->setContent(new LazyResponse($object));
		$response->getHeaders()->addHeaders(array(
			'Content-Type' => $object->getContentType() ?: 'application/octet-stream',
			'Content-Disposition' => ($forceDownload ? 'attachment' : 'inline') .';filename="'. str_replace('"', '\\"', $filename) .'"',
			'Content-Transfer-Encoding' => 'binary',
			'Expires' => '-1 year',
			'Cache-Control' => 'must-revalidate',
			'Pragma' => 'public',
			'Content-Length' => $object->getContentLength(),
		));

		return $response;
	}
public function getResponse ( $ id , $ filename = null , $ forceDownload = false ) { $ object = $ this -> container -> get ( $ id ) ; if ( $ filename === null ) { $ filename = $ object -> getBasename ( ) ; } if ( ! pathinfo ( $ filename , PATHINFO_EXTENSION ) && $ object -> getExtension ( ) ) { $ filename .= '.' . $ object -> getExtension ( ) ; } /** @var HttpResponse $response */ $ response = $ this -> controller -> getResponse ( ) ; $ response -> setContent ( new LazyResponse ( $ object ) ) ; $ response -> getHeaders ( ) -> addHeaders ( array ( 'Content-Type' => $ object -> getContentType ( ) ? : 'application/octet-stream' , 'Content-Disposition' => ( $ forceDownload ? 'attachment' : 'inline' ) . ';filename="' . str_replace ( '"' , '\\"' , $ filename ) . '"' , 'Content-Transfer-Encoding' => 'binary' , 'Expires' => '-1 year' , 'Cache-Control' => 'must-revalidate' , 'Pragma' => 'public' , 'Content-Length' => $ object -> getContentLength ( ) , ) ) ; return $ response ; }
Return a response object for a given file.

@param string $id
@param string $filename Filename to use instead of the file's actual basename
@param bool $forceDownload Whether to force client to download the file

@return HttpResponse
Return a response object for a given file .