Client
extends AbstractTus
in package
Table of Contents
- 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'
- $apiPath : string
- $cache : Cacheable
- $checksum : string
- $checksumAlgorithm : string
- $client : Client
- $dispatcher : EventDispatcherInterface
- $fileName : string
- $filePath : string
- $fileSize : int
- $key : string
- $metadata : array<string|int, mixed>
- $partial : bool
- $partialOffset : int
- $url : string
- __construct() : mixed
- Client constructor.
- addMetadata() : Client
- Add metadata.
- concat() : string
- Concatenate 2 or more partial uploads.
- create() : string
- Create resource with POST request.
- delete() : void
- Send DELETE request.
- event() : EventDispatcherInterface
- Set and get event dispatcher.
- file() : Client
- Set file properties.
- getApiPath() : string
- Get API path.
- getCache() : Cacheable
- Get cache.
- getChecksum() : string
- Get checksum.
- getChecksumAlgorithm() : string
- Get checksum algorithm.
- getClient() : Client
- Get guzzle client.
- getFileName() : string|null
- Get file name.
- getFilePath() : string|null
- Get file path.
- getFileSize() : int
- Get file size.
- getKey() : string
- Get key.
- getMetadata() : array<string|int, mixed>
- Get metadata.
- getOffset() : bool|int
- Returns offset if file is partially uploaded.
- getPartialOffset() : int
- Get partial offset.
- getUrl() : string|null
- Get url.
- isExpired() : bool
- Check if current upload is expired.
- isPartial() : bool
- Check if this is a partial upload request.
- removeMetadata() : Client
- Remove metadata.
- seek() : self
- Set offset and force this to be a partial upload request.
- setApiPath() : self
- Set API path.
- setCache() : self
- Set cache.
- setChecksum() : Client
- Set checksum.
- setChecksumAlgorithm() : Client
- Set checksum algorithm.
- setDispatcher() : self
- Set event dispatcher.
- setFileName() : Client
- Set file name.
- setKey() : Client
- Set key.
- setMetadata() : Client
- Set metadata.
- upload() : int
- Upload file.
- getData() : string
- Get X bytes of data from file.
- getUploadChecksumHeader() : string
- Get upload checksum header.
- getUploadMetadataHeader() : string
- Get metadata for Upload-Metadata header.
- handleClientException() : mixed
- Handle client exception during patch request.
- partial() : void
- Set as partial request.
- sendHeadRequest() : int
- Send HEAD request.
- sendPatchRequest() : int
- Send PATCH request.
Constants
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
Properties
$apiPath
protected
string
$apiPath
= '/files'
$cache
protected
Cacheable
$cache
$checksum
protected
string
$checksum
$checksumAlgorithm
protected
string
$checksumAlgorithm
= 'sha256'
$client
protected
Client
$client
$dispatcher
protected
EventDispatcherInterface
$dispatcher
$fileName
protected
string
$fileName
$filePath
protected
string
$filePath
$fileSize
protected
int
$fileSize
= 0
$key
protected
string
$key
$metadata
protected
array<string|int, mixed>
$metadata
= []
$partial
protected
bool
$partial
= false
$partialOffset
protected
int
$partialOffset
= -1
$url
protected
string
$url
Methods
__construct()
Client constructor.
public
__construct(string $baseUri[, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $baseUri : string
- $options : array<string|int, mixed> = []
Tags
Return values
mixed —addMetadata()
Add metadata.
public
addMetadata(string $key, string $value) : Client
Parameters
- $key : string
- $value : string
Return values
Client —concat()
Concatenate 2 or more partial uploads.
public
concat(string $key, mixed ...$partials) : string
Parameters
- $key : string
- $partials : mixed
Return values
string —create()
Create resource with POST request.
public
create(string $key) : string
Parameters
- $key : string
Tags
Return values
string —delete()
Send DELETE request.
public
delete() : void
Tags
Return values
void —event()
Set and get event dispatcher.
public
event() : EventDispatcherInterface
Return values
EventDispatcherInterface —file()
Set file properties.
public
file(string $file[, string $name = null ]) : Client
Parameters
- $file : string
-
File path.
- $name : string = null
-
File name.
Return values
Client —getApiPath()
Get API path.
public
getApiPath() : string
Return values
string —getCache()
Get cache.
public
getCache() : Cacheable
Return values
Cacheable —getChecksum()
Get checksum.
public
getChecksum() : string
Return values
string —getChecksumAlgorithm()
Get checksum algorithm.
public
getChecksumAlgorithm() : string
Return values
string —getClient()
Get guzzle client.
public
getClient() : Client
Return values
Client —getFileName()
Get file name.
public
getFileName() : string|null
Return values
string|null —getFilePath()
Get file path.
public
getFilePath() : string|null
Return values
string|null —getFileSize()
Get file size.
public
getFileSize() : int
Return values
int —getKey()
Get key.
public
getKey() : string
Return values
string —getMetadata()
Get metadata.
public
getMetadata() : array<string|int, mixed>
Return values
array<string|int, mixed> —getOffset()
Returns offset if file is partially uploaded.
public
getOffset() : bool|int
Return values
bool|int —getPartialOffset()
Get partial offset.
public
getPartialOffset() : int
Return values
int —getUrl()
Get url.
public
getUrl() : string|null
Return values
string|null —isExpired()
Check if current upload is expired.
public
isExpired() : bool
Return values
bool —isPartial()
Check if this is a partial upload request.
public
isPartial() : bool
Return values
bool —removeMetadata()
Remove metadata.
public
removeMetadata(string $key) : Client
Parameters
- $key : string
Return values
Client —seek()
Set offset and force this to be a partial upload request.
public
seek(int $offset) : self
Parameters
- $offset : int
Return values
self —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 —setChecksum()
Set checksum.
public
setChecksum(string $checksum) : Client
Parameters
- $checksum : string
Return values
Client —setChecksumAlgorithm()
Set checksum algorithm.
public
setChecksumAlgorithm(string $algorithm) : Client
Parameters
- $algorithm : string
Return values
Client —setDispatcher()
Set event dispatcher.
public
setDispatcher(EventDispatcherInterface $dispatcher) : self
Parameters
- $dispatcher : EventDispatcherInterface
Return values
self —setFileName()
Set file name.
public
setFileName(string $name) : Client
Parameters
- $name : string
Return values
Client —setKey()
Set key.
public
setKey(string $key) : Client
Parameters
- $key : string
Return values
Client —setMetadata()
Set metadata.
public
setMetadata(array<string|int, mixed> $items) : Client
Parameters
- $items : array<string|int, mixed>
Return values
Client —upload()
Upload file.
public
upload([int $bytes = -1 ]) : int
Parameters
- $bytes : int = -1
-
Bytes to upload
Tags
Return values
int —getData()
Get X bytes of data from file.
protected
getData(int $offset, int $bytes) : string
Parameters
- $offset : int
- $bytes : int
Return values
string —getUploadChecksumHeader()
Get upload checksum header.
protected
getUploadChecksumHeader() : string
Return values
string —getUploadMetadataHeader()
Get metadata for Upload-Metadata header.
protected
getUploadMetadataHeader() : string
Return values
string —handleClientException()
Handle client exception during patch request.
protected
handleClientException(ClientException $e) : mixed
Parameters
- $e : ClientException
Return values
mixed —partial()
Set as partial request.
protected
partial([bool $state = true ]) : void
Parameters
- $state : bool = true
Return values
void —sendHeadRequest()
Send HEAD request.
protected
sendHeadRequest() : int
Tags
Return values
int —sendPatchRequest()
Send PATCH request.
protected
sendPatchRequest(int $bytes, int $offset) : int
Parameters
- $bytes : int
- $offset : int