Server
extends AbstractTus
in package
Table of Contents
- TUS_EXTENSION_CHECKSUM = 'checksum'
- TUS_EXTENSION_CONCATENATION = 'concatenation'
- TUS_EXTENSION_CREATION = 'creation'
- TUS_EXTENSION_EXPIRATION = 'expiration'
- TUS_EXTENSION_TERMINATION = 'termination'
- TUS_EXTENSIONS = [self::TUS_EXTENSION_CREATION, self::TUS_EXTENSION_TERMINATION, self::TUS_EXTENSION_CHECKSUM, self::TUS_EXTENSION_EXPIRATION, self::TUS_EXTENSION_CONCATENATION]
- TUS_PROTOCOL_VERSION = '1.0.0'
- UPLOAD_TYPE_FINAL = 'final'
- UPLOAD_TYPE_PARTIAL = 'partial'
- HEADER_CONTENT_TYPE = 'application/offset+octet-stream'
- PARTIAL_UPLOAD_NAME_SEPARATOR = '_'
- UPLOAD_TYPE_NORMAL = 'normal'
- DEFAULT_CHECKSUM_ALGORITHM = 'sha256'
- HTTP_CHECKSUM_MISMATCH = 460
- $apiPath : string
- $cache : Cacheable
- $dispatcher : EventDispatcherInterface
- $maxUploadSize : int
- $middleware : Middleware
- $request : Request
- $response : Response
- $uploadDir : string
- $uploadKey : string
- __call() : Response
- No other methods are allowed.
- __construct() : mixed
- TusServer constructor.
- event() : EventDispatcherInterface
- Set and get event dispatcher.
- getApiPath() : string
- Get API path.
- getCache() : Cacheable
- Get cache.
- getChecksumAlgorithm() : string|null
- Get checksum algorithm.
- getMaxUploadSize() : int
- Get max upload size.
- getRequest() : Request
- Get request.
- getResponse() : Response
- Get request.
- getServerChecksum() : string
- Get file checksum.
- getUploadDir() : string
- Get upload dir.
- getUploadKey() : string|Response
- Get upload key from header.
- handleExpiration() : array<string|int, mixed>
- Delete expired resources.
- middleware() : Middleware
- Get middleware.
- serve() : Response|BinaryFileResponse
- Handle all HTTP request.
- setApiPath() : self
- Set API path.
- setCache() : self
- Set cache.
- setDispatcher() : self
- Set event dispatcher.
- setMaxUploadSize() : Server
- Set max upload size.
- setMiddleware() : self
- Set middleware.
- setUploadDir() : Server
- Set upload dir.
- setUploadKey() : Server
- Set upload key.
- applyMiddleware() : void
- Apply middleware.
- buildFile() : File
- Build file object.
- getClientChecksum() : string|Response
- Verify and get upload checksum from header.
- getHeadersForHeadRequest() : array<string|int, mixed>
- Get required headers for head request.
- getPartialsMeta() : array<string|int, mixed>
- Get metadata of partials.
- getPathForPartialUpload() : string
- Get path for partial upload.
- getSupportedHashAlgorithms() : string
- Get list of supported hash algorithms.
- handleConcatenation() : Response
- Handle file concatenation.
- handleDelete() : Response
- Handle DELETE request.
- handleDownload() : BinaryFileResponse|Response
- Handle Download request.
- handleGet() : BinaryFileResponse|Response
- Handle GET request.
- handleHead() : Response
- Handle HEAD request.
- handleOptions() : Response
- Handle OPTIONS request.
- handlePatch() : Response
- Handle PATCH request.
- handlePost() : Response
- Handle POST request.
- isExpired() : bool
- Get expired but incomplete uploads.
- verifyChecksum() : bool
- Verify checksum if available.
- verifyPatchRequest() : int
- Verify PATCH request.
- verifyUploadSize() : bool
- Verify max upload size.
Constants
TUS_EXTENSION_CHECKSUM
public
mixed
TUS_EXTENSION_CHECKSUM
= 'checksum'
Tags
TUS_EXTENSION_CONCATENATION
public
mixed
TUS_EXTENSION_CONCATENATION
= 'concatenation'
Tags
TUS_EXTENSION_CREATION
public
mixed
TUS_EXTENSION_CREATION
= 'creation'
Tags
TUS_EXTENSION_EXPIRATION
public
mixed
TUS_EXTENSION_EXPIRATION
= 'expiration'
Tags
TUS_EXTENSION_TERMINATION
public
mixed
TUS_EXTENSION_TERMINATION
= 'termination'
Tags
TUS_EXTENSIONS
public
mixed
TUS_EXTENSIONS
= [self::TUS_EXTENSION_CREATION, self::TUS_EXTENSION_TERMINATION, self::TUS_EXTENSION_CHECKSUM, self::TUS_EXTENSION_EXPIRATION, self::TUS_EXTENSION_CONCATENATION]
Tags
TUS_PROTOCOL_VERSION
public
mixed
TUS_PROTOCOL_VERSION
= '1.0.0'
Tags
UPLOAD_TYPE_FINAL
public
mixed
UPLOAD_TYPE_FINAL
= 'final'
Tags
UPLOAD_TYPE_PARTIAL
public
mixed
UPLOAD_TYPE_PARTIAL
= 'partial'
Tags
HEADER_CONTENT_TYPE
protected
mixed
HEADER_CONTENT_TYPE
= 'application/offset+octet-stream'
Tags
PARTIAL_UPLOAD_NAME_SEPARATOR
protected
mixed
PARTIAL_UPLOAD_NAME_SEPARATOR
= '_'
Tags
UPLOAD_TYPE_NORMAL
protected
mixed
UPLOAD_TYPE_NORMAL
= 'normal'
Tags
DEFAULT_CHECKSUM_ALGORITHM
private
mixed
DEFAULT_CHECKSUM_ALGORITHM
= 'sha256'
Tags
HTTP_CHECKSUM_MISMATCH
private
mixed
HTTP_CHECKSUM_MISMATCH
= 460
Tags
Properties
$apiPath
protected
string
$apiPath
= '/files'
$cache
protected
Cacheable
$cache
$dispatcher
protected
EventDispatcherInterface
$dispatcher
$maxUploadSize
protected
int
$maxUploadSize
= 0
Max upload size in bytes Default 0, no restriction.
$middleware
protected
Middleware
$middleware
$request
protected
Request
$request
$response
protected
Response
$response
$uploadDir
protected
string
$uploadDir
$uploadKey
protected
string
$uploadKey
Methods
__call()
No other methods are allowed.
public
__call(string $method, array<string|int, mixed> $params) : Response
Parameters
- $method : string
- $params : array<string|int, mixed>
Return values
Response —__construct()
TusServer constructor.
public
__construct([Cacheable|string $cacheAdapter = 'file' ]) : mixed
Parameters
- $cacheAdapter : Cacheable|string = 'file'
Tags
Return values
mixed —event()
Set and get event dispatcher.
public
event() : EventDispatcherInterface
Return values
EventDispatcherInterface —getApiPath()
Get API path.
public
getApiPath() : string
Return values
string —getCache()
Get cache.
public
getCache() : Cacheable
Return values
Cacheable —getChecksumAlgorithm()
Get checksum algorithm.
public
getChecksumAlgorithm() : string|null
Return values
string|null —getMaxUploadSize()
Get max upload size.
public
getMaxUploadSize() : int
Return values
int —getRequest()
Get request.
public
getRequest() : Request
Return values
Request —getResponse()
Get request.
public
getResponse() : Response
Return values
Response —getServerChecksum()
Get file checksum.
public
getServerChecksum(string $filePath) : string
Parameters
- $filePath : string
Return values
string —getUploadDir()
Get upload dir.
public
getUploadDir() : string
Return values
string —getUploadKey()
Get upload key from header.
public
getUploadKey() : string|Response
Return values
string|Response —handleExpiration()
Delete expired resources.
public
handleExpiration() : array<string|int, mixed>
Return values
array<string|int, mixed> —middleware()
Get middleware.
public
middleware() : Middleware
Return values
Middleware —serve()
Handle all HTTP request.
public
serve() : Response|BinaryFileResponse
Return values
Response|BinaryFileResponse —setApiPath()
Set API path.
public
setApiPath(string $path) : self
Parameters
- $path : string
Return values
self —setCache()
Set cache.
public
setCache(mixed $cache) : self
Parameters
- $cache : mixed
Tags
Return values
self —setDispatcher()
Set event dispatcher.
public
setDispatcher(EventDispatcherInterface $dispatcher) : self
Parameters
- $dispatcher : EventDispatcherInterface
Return values
self —setMaxUploadSize()
Set max upload size.
public
setMaxUploadSize(int $uploadSize) : Server
Parameters
- $uploadSize : int
Return values
Server —setMiddleware()
Set middleware.
public
setMiddleware(Middleware $middleware) : self
Parameters
- $middleware : Middleware
Return values
self —setUploadDir()
Set upload dir.
public
setUploadDir(string $path) : Server
Parameters
- $path : string
Return values
Server —setUploadKey()
Set upload key.
public
setUploadKey(string $key) : Server
Parameters
- $key : string
Return values
Server —applyMiddleware()
Apply middleware.
protected
applyMiddleware() : void
Return values
void —buildFile()
Build file object.
protected
buildFile(array<string|int, mixed> $meta) : File
Parameters
- $meta : array<string|int, mixed>
Return values
File —getClientChecksum()
Verify and get upload checksum from header.
protected
getClientChecksum() : string|Response
Return values
string|Response —getHeadersForHeadRequest()
Get required headers for head request.
protected
getHeadersForHeadRequest(array<string|int, mixed> $fileMeta) : array<string|int, mixed>
Parameters
- $fileMeta : array<string|int, mixed>
Return values
array<string|int, mixed> —getPartialsMeta()
Get metadata of partials.
protected
getPartialsMeta(array<string|int, mixed> $partials) : array<string|int, mixed>
Parameters
- $partials : array<string|int, mixed>
Return values
array<string|int, mixed> —getPathForPartialUpload()
Get path for partial upload.
protected
getPathForPartialUpload(string $key) : string
Parameters
- $key : string
Return values
string —getSupportedHashAlgorithms()
Get list of supported hash algorithms.
protected
getSupportedHashAlgorithms() : string
Return values
string —handleConcatenation()
Handle file concatenation.
protected
handleConcatenation(string $fileName, string $filePath) : Response
Parameters
- $fileName : string
- $filePath : string
Return values
Response —handleDelete()
Handle DELETE request.
protected
handleDelete() : Response
Return values
Response —handleDownload()
Handle Download request.
protected
handleDownload() : BinaryFileResponse|Response
Return values
BinaryFileResponse|Response —handleGet()
Handle GET request.
protected
handleGet() : BinaryFileResponse|Response
As per RFC7231, we need to treat HEAD and GET as an identical request. All major PHP frameworks follows the same and silently transforms each HEAD requests to GET.
Return values
BinaryFileResponse|Response —handleHead()
Handle HEAD request.
protected
handleHead() : Response
Return values
Response —handleOptions()
Handle OPTIONS request.
protected
handleOptions() : Response
Return values
Response —handlePatch()
Handle PATCH request.
protected
handlePatch() : Response
Return values
Response —handlePost()
Handle POST request.
protected
handlePost() : Response
Return values
Response —isExpired()
Get expired but incomplete uploads.
protected
isExpired(array<string|int, mixed>|null $contents) : bool
Parameters
- $contents : array<string|int, mixed>|null
Return values
bool —verifyChecksum()
Verify checksum if available.
protected
verifyChecksum(string $checksum, string $filePath) : bool
Parameters
- $checksum : string
- $filePath : string
Return values
bool —verifyPatchRequest()
Verify PATCH request.
protected
verifyPatchRequest(array<string|int, mixed> $meta) : int
Parameters
- $meta : array<string|int, mixed>
Return values
int —verifyUploadSize()
Verify max upload size.
protected
verifyUploadSize() : bool