Client
in package
Table of Contents
- MAX_CHUNK_SIZE = 1024 * 1024 * 150
- THUMBNAIL_FORMAT_JPEG = 'jpeg'
- THUMBNAIL_FORMAT_PNG = 'png'
- THUMBNAIL_SIZE_L = 'w640h480'
- THUMBNAIL_SIZE_M = 'w128h128'
- THUMBNAIL_SIZE_S = 'w64h64'
- THUMBNAIL_SIZE_XL = 'w1024h768'
- THUMBNAIL_SIZE_XS = 'w32h32'
- UPLOAD_SESSION_APPEND = 1
- UPLOAD_SESSION_START = 0
- $accessToken : string
- $client : Client
- $maxChunkSize : int
- $maxUploadChunkRetries : int
- __construct() : mixed
- contentEndpointRequest() : ResponseInterface
- copy() : array<string|int, mixed>
- Copy a file or folder to a different location in the user's Dropbox.
- createFolder() : array<string|int, mixed>
- Create a folder at a given path.
- createSharedLinkWithSettings() : mixed
- Create a shared link with custom settings.
- delete() : array<string|int, mixed>
- Delete the file or folder at a given path.
- download() : resource
- Download a file from a user's Dropbox.
- getAccessToken() : string
- Get the access token.
- getAccountInfo() : array<string|int, mixed>
- Get Account Info for current authenticated user.
- getMetadata() : array<string|int, mixed>
- Returns the metadata for a file or folder.
- getTemporaryLink() : string
- Get a temporary link to stream content of a file.
- getThumbnail() : string
- Get a thumbnail for an image.
- listFolder() : array<string|int, mixed>
- Starts returning the contents of a folder.
- listFolderContinue() : array<string|int, mixed>
- Once a cursor has been retrieved from list_folder, use this to paginate through all files and retrieve updates to the folder, following the same rules as documented for list_folder.
- listSharedLinks() : array<string|int, mixed>
- List shared links.
- move() : array<string|int, mixed>
- Move a file or folder to a different location in the user's Dropbox.
- revokeToken() : mixed
- Revoke current access token.
- rpcEndpointRequest() : array<string|int, mixed>
- search() : mixed
- Search a file or folder in the user's Dropbox.
- setAccessToken() : self
- Set the access token.
- upload() : array<string|int, mixed>
- Create a new file with the contents provided in the request.
- uploadChunked() : array<string|int, mixed>
- Upload file split in chunks. This allows uploading large files, since Dropbox API v2 limits the content size to 150MB.
- uploadSessionAppend() : UploadSessionCursor
- Append more data to an upload session.
- uploadSessionFinish() : array<string|int, mixed>
- Finish an upload session and save the uploaded data to the given file path.
- uploadSessionStart() : UploadSessionCursor
- Upload sessions allow you to upload a single file in one or more requests, for example where the size of the file is greater than 150 MB.
- determineException() : Exception
- getEndpointUrl() : string
- getHeaders() : array<string|int, mixed>
- Get the HTTP headers.
- getStream() : PumpStream|Stream
- isPipe() : bool
- Check if the contents is a pipe stream (not seekable, no size defined).
- normalizePath() : string
- shouldUploadChunked() : bool
- The file should be uploaded in chunks if it size exceeds the 150 MB threshold or if the resource size could not be determined (eg. a popen() stream).
- uploadChunk() : UploadSessionCursor
Constants
MAX_CHUNK_SIZE
public
mixed
MAX_CHUNK_SIZE
= 1024 * 1024 * 150
THUMBNAIL_FORMAT_JPEG
public
mixed
THUMBNAIL_FORMAT_JPEG
= 'jpeg'
THUMBNAIL_FORMAT_PNG
public
mixed
THUMBNAIL_FORMAT_PNG
= 'png'
THUMBNAIL_SIZE_L
public
mixed
THUMBNAIL_SIZE_L
= 'w640h480'
THUMBNAIL_SIZE_M
public
mixed
THUMBNAIL_SIZE_M
= 'w128h128'
THUMBNAIL_SIZE_S
public
mixed
THUMBNAIL_SIZE_S
= 'w64h64'
THUMBNAIL_SIZE_XL
public
mixed
THUMBNAIL_SIZE_XL
= 'w1024h768'
THUMBNAIL_SIZE_XS
public
mixed
THUMBNAIL_SIZE_XS
= 'w32h32'
UPLOAD_SESSION_APPEND
public
mixed
UPLOAD_SESSION_APPEND
= 1
UPLOAD_SESSION_START
public
mixed
UPLOAD_SESSION_START
= 0
Properties
$accessToken
protected
string
$accessToken
$client
protected
Client
$client
$maxChunkSize
protected
int
$maxChunkSize
$maxUploadChunkRetries
protected
int
$maxUploadChunkRetries
Methods
__construct()
public
__construct(string $accessToken[, Client|null $client = null ][, int $maxChunkSize = self::MAX_CHUNK_SIZE ], int $maxUploadChunkRetries) : mixed
Parameters
- $accessToken : string
- $client : Client|null = null
- $maxChunkSize : int = self::MAX_CHUNK_SIZE
-
Set max chunk size per request (determines when to switch from "one shot upload" to upload session and defines chunk size for uploads via session).
- $maxUploadChunkRetries : int
-
How many times to retry an upload session start or append after RequestException.
Return values
mixed —contentEndpointRequest()
public
contentEndpointRequest(string $endpoint, array<string|int, mixed> $arguments[, string|resource|StreamInterface $body = '' ]) : ResponseInterface
Parameters
- $endpoint : string
- $arguments : array<string|int, mixed>
- $body : string|resource|StreamInterface = ''
Tags
Return values
ResponseInterface —copy()
Copy a file or folder to a different location in the user's Dropbox.
public
copy(string $fromPath, string $toPath) : array<string|int, mixed>
If the source path is a folder all its contents will be copied.
Parameters
- $fromPath : string
- $toPath : string
Tags
Return values
array<string|int, mixed> —createFolder()
Create a folder at a given path.
public
createFolder(string $path) : array<string|int, mixed>
Parameters
- $path : string
Tags
Return values
array<string|int, mixed> —createSharedLinkWithSettings()
Create a shared link with custom settings.
public
createSharedLinkWithSettings(string $path[, array<string|int, mixed> $settings = [] ]) : mixed
If no settings are given then the default visibility is RequestedVisibility.public. The resolved visibility, though, may depend on other aspects such as team and shared folder settings). Only for paid users.
Parameters
- $path : string
- $settings : array<string|int, mixed> = []
Tags
Return values
mixed —delete()
Delete the file or folder at a given path.
public
delete(string $path) : array<string|int, mixed>
If the path is a folder, all its contents will be deleted too. A successful response indicates that the file or folder was deleted.
Parameters
- $path : string
Tags
Return values
array<string|int, mixed> —download()
Download a file from a user's Dropbox.
public
download(string $path) : resource
Parameters
- $path : string
Tags
Return values
resource —getAccessToken()
Get the access token.
public
getAccessToken() : string
Return values
string —getAccountInfo()
Get Account Info for current authenticated user.
public
getAccountInfo() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getMetadata()
Returns the metadata for a file or folder.
public
getMetadata(string $path) : array<string|int, mixed>
Note: Metadata for the root folder is unsupported.
Parameters
- $path : string
Tags
Return values
array<string|int, mixed> —getTemporaryLink()
Get a temporary link to stream content of a file.
public
getTemporaryLink(string $path) : string
This link will expire in four hours and afterwards you will get 410 Gone. Content-Type of the link is determined automatically by the file's mime type.
Parameters
- $path : string
Tags
Return values
string —getThumbnail()
Get a thumbnail for an image.
public
getThumbnail(string $path[, string $format = 'jpeg' ][, string $size = 'w64h64' ]) : string
This method currently supports files with the following file extensions: jpg, jpeg, png, tiff, tif, gif and bmp.
Photos that are larger than 20MB in size won't be converted to a thumbnail.
Parameters
- $path : string
- $format : string = 'jpeg'
- $size : string = 'w64h64'
Tags
Return values
string —listFolder()
Starts returning the contents of a folder.
public
listFolder([string $path = '' ][, bool $recursive = false ]) : array<string|int, mixed>
If the result's ListFolderResult.has_more field is true, call list_folder/continue with the returned ListFolderResult.cursor to retrieve more entries.
Note: auth.RateLimitError may be returned if multiple list_folder or list_folder/continue calls with same parameters are made simultaneously by same API app for same user. If your app implements retry logic, please hold off the retry until the previous request finishes.
Parameters
- $path : string = ''
- $recursive : bool = false
Tags
Return values
array<string|int, mixed> —listFolderContinue()
Once a cursor has been retrieved from list_folder, use this to paginate through all files and retrieve updates to the folder, following the same rules as documented for list_folder.
public
listFolderContinue([string $cursor = '' ]) : array<string|int, mixed>
Parameters
- $cursor : string = ''
Tags
Return values
array<string|int, mixed> —listSharedLinks()
List shared links.
public
listSharedLinks([string $path = null ][, bool $direct_only = false ][, string $cursor = null ]) : array<string|int, mixed>
For empty path returns a list of all shared links. For non-empty path returns a list of all shared links with access to the given path.
If direct_only is set true, only direct links to the path will be returned, otherwise it may return link to the path itself and parent folders as described on docs.
Parameters
- $path : string = null
- $direct_only : bool = false
- $cursor : string = null
Tags
Return values
array<string|int, mixed> —move()
Move a file or folder to a different location in the user's Dropbox.
public
move(string $fromPath, string $toPath) : array<string|int, mixed>
If the source path is a folder all its contents will be moved.
Parameters
- $fromPath : string
- $toPath : string
Tags
Return values
array<string|int, mixed> —revokeToken()
Revoke current access token.
public
revokeToken() : mixed
Tags
Return values
mixed —rpcEndpointRequest()
public
rpcEndpointRequest(string $endpoint[, array<string|int, mixed> $parameters = null ]) : array<string|int, mixed>
Parameters
- $endpoint : string
- $parameters : array<string|int, mixed> = null
Return values
array<string|int, mixed> —search()
Search a file or folder in the user's Dropbox.
public
search(string $query[, bool $includeHighlights = false ]) : mixed
Parameters
- $query : string
- $includeHighlights : bool = false
Tags
Return values
mixed —setAccessToken()
Set the access token.
public
setAccessToken(string $accessToken) : self
Parameters
- $accessToken : string
Return values
self —upload()
Create a new file with the contents provided in the request.
public
upload(string $path, string|resource $contents[, string $mode = 'add' ]) : array<string|int, mixed>
Do not use this to upload a file larger than 150 MB. Instead, create an upload session with upload_session/start.
Parameters
- $path : string
- $contents : string|resource
- $mode : string = 'add'
Tags
Return values
array<string|int, mixed> —uploadChunked()
Upload file split in chunks. This allows uploading large files, since Dropbox API v2 limits the content size to 150MB.
public
uploadChunked(string $path, string|resource $contents[, string $mode = 'add' ][, int $chunkSize = null ]) : array<string|int, mixed>
The chunk size will affect directly the memory usage, so be careful. Large chunks tends to speed up the upload, while smaller optimizes memory usage.
Parameters
- $path : string
- $contents : string|resource
- $mode : string = 'add'
- $chunkSize : int = null
Return values
array<string|int, mixed> —uploadSessionAppend()
Append more data to an upload session.
public
uploadSessionAppend(string|StreamInterface $contents, UploadSessionCursor $cursor[, bool $close = false ]) : UploadSessionCursor
When the parameter close is set, this call will close the session. A single request should not upload more than 150 MB.
Parameters
- $contents : string|StreamInterface
- $cursor : UploadSessionCursor
- $close : bool = false
Tags
Return values
UploadSessionCursor —uploadSessionFinish()
Finish an upload session and save the uploaded data to the given file path.
public
uploadSessionFinish(string|StreamInterface $contents, UploadSessionCursor $cursor, string $path[, string|array<string|int, mixed> $mode = 'add' ][, bool $autorename = false ][, bool $mute = false ]) : array<string|int, mixed>
A single request should not upload more than 150 MB.
Parameters
- $contents : string|StreamInterface
- $cursor : UploadSessionCursor
- $path : string
- $mode : string|array<string|int, mixed> = 'add'
- $autorename : bool = false
- $mute : bool = false
Tags
Return values
array<string|int, mixed> —uploadSessionStart()
Upload sessions allow you to upload a single file in one or more requests, for example where the size of the file is greater than 150 MB.
public
uploadSessionStart(string|StreamInterface $contents[, bool $close = false ]) : UploadSessionCursor
This call starts a new upload session with the given data.
Parameters
- $contents : string|StreamInterface
- $close : bool = false
Tags
Return values
UploadSessionCursor —determineException()
protected
determineException(ClientException $exception) : Exception
Parameters
- $exception : ClientException
Return values
Exception —getEndpointUrl()
protected
getEndpointUrl(string $subdomain, string $endpoint) : string
Parameters
- $subdomain : string
- $endpoint : string
Return values
string —getHeaders()
Get the HTTP headers.
protected
getHeaders([array<string|int, mixed> $headers = [] ]) : array<string|int, mixed>
Parameters
- $headers : array<string|int, mixed> = []
Return values
array<string|int, mixed> —getStream()
protected
getStream( $contents) : PumpStream|Stream
Parameters
Return values
PumpStream|Stream —isPipe()
Check if the contents is a pipe stream (not seekable, no size defined).
protected
isPipe(string|resource $contents) : bool
Parameters
- $contents : string|resource
Return values
bool —normalizePath()
protected
normalizePath(string $path) : string
Parameters
- $path : string
Return values
string —shouldUploadChunked()
The file should be uploaded in chunks if it size exceeds the 150 MB threshold or if the resource size could not be determined (eg. a popen() stream).
protected
shouldUploadChunked(string|resource $contents) : bool
Parameters
- $contents : string|resource
Return values
bool —uploadChunk()
protected
uploadChunk(int $type, Stream &$stream, int $chunkSize[, UploadSessionCursor|null $cursor = null ]) : UploadSessionCursor
Parameters
- $type : int
- $stream : Stream
- $chunkSize : int
- $cursor : UploadSessionCursor|null = null