public function response($path, $name = null, array $headers = [], $disposition = 'inline')
    {
        $response = new StreamedResponse;

        $disposition = $response->headers->makeDisposition($disposition, $name ?? basename($path));

        $response->headers->replace($headers + [
            'Content-Type' => $this->mimeType($path),
            'Content-Length' => $this->size($path),
            'Content-Disposition' => $disposition,
        ]);

        $response->setCallback(function () use ($path) {
            $stream = $this->readStream($path);
            fpassthru($stream);
            fclose($stream);
        });

        return $response;
    }
public function response($path, $name = null, array $headers = [], $disposition = 'inline')
    {
        $response = new StreamedResponse;

        $disposition = $response->headers->makeDisposition($disposition, $name ?? basename($path));

        $response->headers->replace($headers + [
            'Content-Type' => $this->mimeType($path),
            'Content-Length' => $this->size($path),
            'Content-Disposition' => $disposition,
        ]);

        $response->setCallback(function () use ($path) {
            $stream = $this->readStream($path);
            fpassthru($stream);
            fclose($stream);
        });

        return $response;
    }
public function response ( $ path , $ name = null , array $ headers = [ ] , $ disposition = 'inline' ) { $ response = new StreamedResponse ; $ disposition = $ response -> headers -> makeDisposition ( $ disposition , $ name ?? basename ( $ path ) ) ; $ response -> headers -> replace ( $ headers + [ 'Content-Type' => $ this -> mimeType ( $ path ) , 'Content-Length' => $ this -> size ( $ path ) , 'Content-Disposition' => $ disposition , ] ) ; $ response -> setCallback ( function ( ) use ( $ path ) { $ stream = $ this -> readStream ( $ path ) ; fpassthru ( $ stream ) ; fclose ( $ stream ) ; } ) ; return $ response ; }
Create a streamed response for a given file.

@param  string  $path
@param  string|null  $name
@param  array|null  $headers
@param  string|null  $disposition
@return \Symfony\Component\HttpFoundation\StreamedResponse
Create a streamed response for a given file .