class BinaryFileResponse extends Response

BinaryFileResponse represents an HTTP response delivering a file.

Methods

__construct(SplFileInfo|string $file, int $status = 200, array $headers = array(), bool $public = true, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)

No description

create(SplFileInfo|string $file = null, int $status = 200, array $headers = array(), bool $public = true, null|string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)

No description

$this
setFile(SplFileInfo|string $file, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)

Sets the file to stream.

getFile()

Gets the file.

setAutoLastModified()

Automatically sets the Last-Modified header according the file modification date.

setAutoEtag()

Automatically sets the ETag header according to the checksum of the file.

$this
setContentDisposition(string $disposition, string $filename = '', string $filenameFallback = '')

Sets the Content-Disposition header with the given filename.

prepare(Request $request)

{@inheritdoc}

sendContent()

Sends the file.

setContent($content)

{@inheritdoc}

false
getContent()

{@inheritdoc}

static 
trustXSendfileTypeHeader()

Trust X-Sendfile-Type header.

$this
deleteFileAfterSend(bool $shouldDelete)

If this is set to true, the file will be unlinked after the request is send Note: If the X-Sendfile header is used, the deleteFileAfterSend setting will not be used.

Details

at line line 47
__construct(SplFileInfo|string $file, int $status = 200, array $headers = array(), bool $public = true, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)

Parameters

SplFileInfo|string $file The file to stream
int $status The response status code
array $headers An array of response headers
bool $public Files are public by default
string $contentDisposition The type of Content-Disposition to set automatically with the filename
bool $autoEtag Whether the ETag header should be automatically set
bool $autoLastModified Whether the Last-Modified header should be automatically set

at line line 69
static BinaryFileResponse create(SplFileInfo|string $file = null, int $status = 200, array $headers = array(), bool $public = true, null|string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)

Parameters

SplFileInfo|string $file The file to stream
int $status The response status code
array $headers An array of response headers
bool $public Files are public by default
null|string $contentDisposition The type of Content-Disposition to set automatically with the filename
bool $autoEtag Whether the ETag header should be automatically set
bool $autoLastModified Whether the Last-Modified header should be automatically set

Return Value

BinaryFileResponse

at line line 86
$this setFile(SplFileInfo|string $file, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)

Sets the file to stream.

Parameters

SplFileInfo|string $file The file to stream
string $contentDisposition
bool $autoEtag
bool $autoLastModified

Return Value

$this

Exceptions

FileException

at line line 122
File getFile()

Gets the file.

Return Value

File The file to stream

at line line 130
setAutoLastModified()

Automatically sets the Last-Modified header according the file modification date.

at line line 140
setAutoEtag()

Automatically sets the ETag header according to the checksum of the file.

at line line 156
$this setContentDisposition(string $disposition, string $filename = '', string $filenameFallback = '')

Sets the Content-Disposition header with the given filename.

Parameters

string $disposition ResponseHeaderBag::DISPOSITIONINLINE or ResponseHeaderBag::DISPOSITIONATTACHMENT
string $filename Optionally use this UTF-8 encoded filename instead of the real name of the file
string $filenameFallback A fallback filename, containing only ASCII characters. Defaults to an automatically encoded filename

Return Value

$this

at line line 185
prepare(Request $request)

{@inheritdoc}

Parameters

Request $request

at line line 290
sendContent()

Sends the file.

{@inheritdoc}

at line line 320
setContent($content)

{@inheritdoc}

Parameters

$content

Exceptions

LogicException when the content is not null

at line line 332
false getContent()

{@inheritdoc}

Return Value

false

at line line 340
static trustXSendfileTypeHeader()

Trust X-Sendfile-Type header.

at line line 353
$this deleteFileAfterSend(bool $shouldDelete)

If this is set to true, the file will be unlinked after the request is send Note: If the X-Sendfile header is used, the deleteFileAfterSend setting will not be used.

Parameters

bool $shouldDelete

Return Value

$this