class FlysystemFileResponse extends Response (View source)

Heavily based on BinaryFileResponse represents an HTTP response delivering a file.

Properties

static protected $trustXSendfileTypeHeader
protected File $file
protected FilesystemInterface $filesystem
protected $offset
protected $maxlen

Methods

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

No description

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

No description

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

Sets the file to stream.

File
getFile()

Gets the file.

$this
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}

hasValidIfRangeHeader($header)

No description

sendContent()

Sends the file.

setContent($content)

{@inheritdoc}

false
getContent()

{@inheritdoc}

static 
trustXSendfileTypeHeader()

Trust X-Sendfile-Type header.

Details

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

Parameters

File $file The file to stream
FilesystemInterface $filesystem The filesystem instance to get info with
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

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

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

Return Value

FlysystemFileResponse

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

Sets the file to stream.

Parameters

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

Return Value

$this

Exceptions

FileException

File getFile()

Gets the file.

Return Value

File The file to stream

$this setAutoEtag()

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

Return Value

$this

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

Sets the Content-Disposition header with the given filename.

Parameters

string $disposition ResponseHeaderBag::DISPOSITION_INLINE or ResponseHeaderBag::DISPOSITION_ATTACHMENT
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

prepare(Request $request)

{@inheritdoc}

Parameters

Request $request

private hasValidIfRangeHeader($header)

Parameters

$header

sendContent()

Sends the file.

{@inheritdoc}

setContent($content)

{@inheritdoc}

Parameters

$content

Exceptions

LogicException when the content is not null

false getContent()

{@inheritdoc}

Return Value

false

static trustXSendfileTypeHeader()

Trust X-Sendfile-Type header.