class File implements ResponseSenderInterface

File response.

Properties

protected FileSystem $fileSystem File system instance.
protected string $filePath File path.
protected int $fileSize File size.
protected string $fileName File name.
protected string $disposition Content disposition.
protected string $contentType Content type.
protected Closure $callback Callback.

Methods

__construct(FileSystem $fileSystem, string $file)

Constructor.

setName(string $name)

Sets the file name.

setDisposition(string $disposition)

Sets the content disposition.

setType(string $type)

Sets the content type.

done(Closure $callback)

Sets the callback closure.

string
getName()

Returns the file name.

string
getDisposition()

Returns the content disposition.

string
getContenType()

Returns the content type.

array|false
calculateRange(string $range)

Calculates the content range that should be served.

sendFile(int $start, int $end)

Sends the file.

send(Request $request, Response $response)

Sends the response.

Details

at line 96
__construct(FileSystem $fileSystem, string $file)

Constructor.

Parameters

FileSystem $fileSystem FileSytem instance
string $file File path

Exceptions

RuntimeException

at line 116
File setName(string $name)

Sets the file name.

Parameters

string $name File name

Return Value

File

at line 129
File setDisposition(string $disposition)

Sets the content disposition.

Parameters

string $disposition Content disposition

Return Value

File

at line 142
File setType(string $type)

Sets the content type.

Parameters

string $type Mime type

Return Value

File

at line 155
File done(Closure $callback)

Sets the callback closure.

Parameters

Closure $callback Callback closure

Return Value

File

at line 167
protected string getName()

Returns the file name.

Return Value

string

at line 177
protected string getDisposition()

Returns the content disposition.

Return Value

string

at line 187
protected string getContenType()

Returns the content type.

Return Value

string

at line 198
protected array|false calculateRange(string $range)

Calculates the content range that should be served.

Parameters

string $range Request range

Return Value

array|false

at line 250
protected sendFile(int $start, int $end)

Sends the file.

Parameters

int $start Starting point
int $end Ending point

at line 286
send(Request $request, Response $response)

Sends the response.

Parameters

Request $request Request instance
Response $response Response instance