class Dropbox (View source)

Dropbox

Constants

AUTO_CHUNKED_UPLOAD_THRESHOLD

Uploading a file with the 'uploadFile' method, with the file's size less than this value (~8 MB), the simple upload method will be used, if the file size exceed this value (~8 MB), the startUploadSession, appendUploadSession & finishUploadSession methods will be used to upload the file in chunks.

DEFAULT_CHUNK_SIZE

The Chunk Size the file will be split into and uploaded (~4 MB)

METADATA_HEADER

Response header containing file metadata

Properties

protected DropboxApp $app The Dropbox App
protected string $accessToken OAuth2 Access Token
protected DropboxClient $client Dropbox Client
protected OAuth2Client $oAuth2Client OAuth2 Client
protected RandomStringGeneratorInterface $randomStringGenerator Random String Generator
protected PersistentDataStoreInterface $persistentDataStore Persistent Data Store

Methods

__construct(DropboxApp $app, array $config = array())

Create a new Dropbox instance

getClient()

Get the Client

string
getAccessToken()

Get the Access Token.

getApp()

Get the Dropbox App.

getOAuth2Client()

Get OAuth2Client

getRandomStringGenerator()

Get the Random String Generator

getAuthHelper()

Get Dropbox Auth Helper

setAccessToken(string $accessToken)

Set the Access Token.

sendRequest(string $method, string $endpoint, string $endpointType = 'api', array $params = array(), string $accessToken = null)

Make Request to the API

postToAPI(string $endpoint, array $params = array(), string $accessToken = null)

Make a HTTP POST Request to the API endpoint type

postToContent(string $endpoint, array $params = array(), string $accessToken = null)

Make a HTTP POST Request to the Content endpoint type

makeModelFromResponse(DropboxResponse $response)

Make Model from DropboxResponse

makeDropboxFile(string|DropboxFile $dropboxFile, int $maxLength = -1, int $offset = -1)

Make DropboxFile Object

getMetadata(string $path, array $params = array())

Get the Metadata for a file or folder

listFolder(string $path = null, array $params = array())

Get the contents of a Folder

listFolderContinue(string $cursor)

Paginate through all files and retrieve updates to the folder, using the cursor retrieved from listFolder or listFolderContinue

string
listFolderLatestCursor(string $path, array $params = array())

Get a cursor for the folder's state.

listRevisions(string $path, array $params = array())

Get Revisions of a File

search(string $path, string $query, array $params = array())

Search a folder for files/folders

createFolder(string $path)

Create a folder at the given path

delete(string $path)

Delete a file or folder at the given path

FileMetadata|FileMetadata|DeletedMetadata
move(string $fromPath, string $toPath)

Move a file or folder to a different location

FileMetadata|FileMetadata|DeletedMetadata
copy(string $fromPath, string $toPath)

Copy a file or folder to a different location

restore(string $path, string $rev)

Restore a file to the specific version

getCopyReference(string $path)

Get Copy Reference

saveCopyReference(string $path, string $copyReference)

Save Copy Reference

getTemporaryLink(string $path)

Get a temporary link to stream contents of a file

string
saveUrl(string $path, string $url)

Save a specified URL into a file in user's Dropbox

string|FileMetadata
checkJobStatus($asyncJobId)

Save a specified URL into a file in user's Dropbox

upload(string|DropboxFile $dropboxFile, string $path, array $params = array())

Upload a File to Dropbox

simpleUpload(string|DropboxFile $dropboxFile, string $path, array $params = array())

Upload a File to Dropbox in a single request

string
startUploadSession(string|DropboxFile $dropboxFile, int $chunkSize = -1, boolean $close = false)

Start an Upload Session

finishUploadSession(string|DropboxFile $dropboxFile, string $sessionId, int $offset, int $remaining, string $path, array $params = array())

Finish an upload session and save the uploaded data to the given file path

string
appendUploadSession(string|DropboxFile $dropboxFile, string $sessionId, int $offset, int $chunkSize, boolean $close = false)

Append more data to an Upload Session

string
uploadChunked(string|DropboxFile $dropboxFile, string $path, int $fileSize = null, int $chunkSize = null, array $params = array())

Upload file in sessions/chunks

string
getThumbnailSize(string $size)

Get thumbnail size

getThumbnail(string $path, string $size = 'small', string $format = 'jpeg')

Get a thumbnail for an image

download(string $path)

Download a File

array
getMetadataFromResponseHeaders(DropboxResponse $response)

Get metadata from response headers

getCurrentAccount()

Get Current Account

getAccount(string $account_id)

Get Account

getAccounts(array $account_ids = array())

Get Multiple Accounts in one call

array
getSpaceUsage()

Get Space Usage for the current user's account

Details

at line line 103
__construct(DropboxApp $app, array $config = array())

Create a new Dropbox instance

Parameters

DropboxApp $app
array $config Configuration Array

at line line 136
DropboxClient getClient()

Get the Client

Return Value

DropboxClient

at line line 146
string getAccessToken()

Get the Access Token.

Return Value

string Access Token

at line line 156
DropboxApp getApp()

Get the Dropbox App.

Return Value

DropboxApp Dropbox App

at line line 166
OAuth2Client getOAuth2Client()

Get OAuth2Client

Return Value

OAuth2Client

at line line 184
RandomStringGeneratorInterface getRandomStringGenerator()

Get the Random String Generator

at line line 194
PersistentDataStoreInterface getPersistentDataStore()

Get Persistent Data Store

at line line 204
DropboxAuthHelper getAuthHelper()

Get Dropbox Auth Helper

Return Value

DropboxAuthHelper

at line line 220
Dropbox setAccessToken(string $accessToken)

Set the Access Token.

Parameters

string $accessToken Access Token

Return Value

Dropbox Dropbox Client

at line line 240
DropboxResponse sendRequest(string $method, string $endpoint, string $endpointType = 'api', array $params = array(), string $accessToken = null)

Make Request to the API

Parameters

string $method HTTP Request Method
string $endpoint API Endpoint to send Request to
string $endpointType Endpoint type ['api'|'content']
array $params Request Query Params
string $accessToken Access Token to send with the Request

Return Value

DropboxResponse

Exceptions

DropboxClientException

at line line 262
DropboxResponse postToAPI(string $endpoint, array $params = array(), string $accessToken = null)

Make a HTTP POST Request to the API endpoint type

Parameters

string $endpoint API Endpoint to send Request to
array $params Request Query Params
string $accessToken Access Token to send with the Request

Return Value

DropboxResponse

at line line 276
DropboxResponse postToContent(string $endpoint, array $params = array(), string $accessToken = null)

Make a HTTP POST Request to the Content endpoint type

Parameters

string $endpoint Content Endpoint to send Request to
array $params Request Query Params
string $accessToken Access Token to send with the Request

Return Value

DropboxResponse

at line line 288
ModelInterface makeModelFromResponse(DropboxResponse $response)

Make Model from DropboxResponse

Parameters

DropboxResponse $response

Return Value

ModelInterface

at line line 306
DropboxFile makeDropboxFile(string|DropboxFile $dropboxFile, int $maxLength = -1, int $offset = -1)

Make DropboxFile Object

Parameters

string|DropboxFile $dropboxFile DropboxFile object or Path to file
int $maxLength Max Bytes to read from the file
int $offset Seek to specified offset before reading

Return Value

DropboxFile

at line line 334
FileMetadata|FolderMetadata getMetadata(string $path, array $params = array())

Get the Metadata for a file or folder

Parameters

string $path Path of the file or folder
array $params Additional Params

Return Value

FileMetadata|FolderMetadata

at line line 361
MetadataCollection listFolder(string $path = null, array $params = array())

Get the contents of a Folder

Parameters

string $path Path to the folder. Defaults to root.
array $params Additional Params

Return Value

MetadataCollection

at line line 390
MetadataCollection listFolderContinue(string $cursor)

Paginate through all files and retrieve updates to the folder, using the cursor retrieved from listFolder or listFolderContinue

Parameters

string $cursor The cursor returned by your last call to listFolder or listFolderContinue

Return Value

MetadataCollection

at line line 408
string listFolderLatestCursor(string $path, array $params = array())

Get a cursor for the folder's state.

Parameters

string $path Path to the folder. Defaults to root.
array $params Additional Params

Return Value

string The Cursor for the folder's state

at line line 445
ModelCollection listRevisions(string $path, array $params = array())

Get Revisions of a File

Parameters

string $path Path to the file
array $params Additional Params

Return Value

ModelCollection

Search a folder for files/folders

Parameters

string $path Path to search
string $query Search Query
array $params Additional Params

Return Value

SearchResults

at line line 509
FolderMetadata createFolder(string $path)

Create a folder at the given path

Parameters

string $path Path to create

Return Value

FolderMetadata

at line line 535
DeletedMetadata|FileMetadata|FolderMetadata delete(string $path)

Delete a file or folder at the given path

Parameters

string $path Path to file/folder to delete

Return Value

DeletedMetadata|FileMetadata|FolderMetadata

at line line 558
FileMetadata|FileMetadata|DeletedMetadata move(string $fromPath, string $toPath)

Move a file or folder to a different location

Parameters

string $fromPath Path to be moved
string $toPath Path to be moved to

Return Value

FileMetadata|FileMetadata|DeletedMetadata

at line line 582
FileMetadata|FileMetadata|DeletedMetadata copy(string $fromPath, string $toPath)

Copy a file or folder to a different location

Parameters

string $fromPath Path to be copied
string $toPath Path to be copied to

Return Value

FileMetadata|FileMetadata|DeletedMetadata

at line line 606
DeletedMetadata|FileMetadata|FolderMetadata restore(string $path, string $rev)

Restore a file to the specific version

Parameters

string $path Path to the file to restore
string $rev Revision to store for the file

Return Value

DeletedMetadata|FileMetadata|FolderMetadata

at line line 632
CopyReference getCopyReference(string $path)

Get Copy Reference

Parameters

string $path Path to the file or folder to get a copy reference to

Return Value

CopyReference

at line line 657
FileMetadata|FolderMetadata saveCopyReference(string $path, string $copyReference)

Save Copy Reference

Parameters

string $path Path to the file or folder to get a copy reference to
string $copyReference Copy reference returned by getCopyReference

Return Value

FileMetadata|FolderMetadata

Get a temporary link to stream contents of a file

Parameters

string $path Path to the file you want a temporary link to

https://www.dropbox.com/developers/documentation/http/documentation#files-gettemporarylink

Return Value

TemporaryLink

at line line 710
string saveUrl(string $path, string $url)

Save a specified URL into a file in user's Dropbox

Parameters

string $path Path where the URL will be saved
string $url URL to be saved

Return Value

string Async Job ID

at line line 739
string|FileMetadata checkJobStatus($asyncJobId)

Save a specified URL into a file in user's Dropbox

Parameters

$asyncJobId

Return Value

string|FileMetadata Status (failed|in_progress) or FileMetadata (if complete)

at line line 773
FileMetadata upload(string|DropboxFile $dropboxFile, string $path, array $params = array())

Upload a File to Dropbox

Parameters

string|DropboxFile $dropboxFile DropboxFile object or Path to file
string $path Path to upload the file to
array $params Additional Params

Return Value

FileMetadata

at line line 799
FileMetadata simpleUpload(string|DropboxFile $dropboxFile, string $path, array $params = array())

Upload a File to Dropbox in a single request

Parameters

string|DropboxFile $dropboxFile DropboxFile object or Path to file
string $path Path to upload the file to
array $params Additional Params

Return Value

FileMetadata

at line line 827
string startUploadSession(string|DropboxFile $dropboxFile, int $chunkSize = -1, boolean $close = false)

Start an Upload Session

Parameters

string|DropboxFile $dropboxFile DropboxFile object or Path to file
int $chunkSize Size of file chunk to upload
boolean $close Closes the session for "appendUploadSession"

Return Value

string Unique identifier for the upload session

at line line 865
FileMetadata finishUploadSession(string|DropboxFile $dropboxFile, string $sessionId, int $offset, int $remaining, string $path, array $params = array())

Finish an upload session and save the uploaded data to the given file path

Parameters

string|DropboxFile $dropboxFile DropboxFile object or Path to file
string $sessionId Session ID returned by startUploadSession
int $offset The amount of data that has been uploaded so far
int $remaining The amount of data that is remaining
string $path Path to save the file to, on Dropbox
array $params Additional Params

Return Value

FileMetadata

at line line 909
string appendUploadSession(string|DropboxFile $dropboxFile, string $sessionId, int $offset, int $chunkSize, boolean $close = false)

Append more data to an Upload Session

Parameters

string|DropboxFile $dropboxFile DropboxFile object or Path to file
string $sessionId Session ID returned by startUploadSession
int $offset The amount of data that has been uploaded so far
int $chunkSize The amount of data to upload
boolean $close Closes the session for futher "appendUploadSession" calls

Return Value

string Unique identifier for the upload session

at line line 952
string uploadChunked(string|DropboxFile $dropboxFile, string $path, int $fileSize = null, int $chunkSize = null, array $params = array())

Upload file in sessions/chunks

Parameters

string|DropboxFile $dropboxFile DropboxFile object or Path to file
string $path Path to save the file to, on Dropbox
int $fileSize The size of the file
int $chunkSize The amount of data to upload in each chunk
array $params Additional Params

Return Value

string Unique identifier for the upload session

at line line 1010
protected string getThumbnailSize(string $size)

Get thumbnail size

Parameters

string $size Thumbnail Size

Return Value

string

at line line 1035
Thumbnail getThumbnail(string $path, string $size = 'small', string $format = 'jpeg')

Get a thumbnail for an image

Parameters

string $path Path to the file you want a thumbnail to
string $size Size for the thumbnail image ['thumb','small','medium','large','huge']
string $format Format for the thumbnail image ['jpeg'|'png']

Return Value

Thumbnail

at line line 1072
File download(string $path)

Download a File

Parameters

string $path Path to the file you want to download

Return Value

File

at line line 1099
protected array getMetadataFromResponseHeaders(DropboxResponse $response)

Get metadata from response headers

Parameters

DropboxResponse $response

Return Value

array

at line line 1135
Account getCurrentAccount()

Get Current Account

Return Value

Account

at line line 1154
Account getAccount(string $account_id)

Get Account

Parameters

string $account_id Account ID of the account to get details for

Return Value

Account

at line line 1173
AccountList getAccounts(array $account_ids = array())

Get Multiple Accounts in one call

Parameters

array $account_ids

Return Value

AccountList

at line line 1190
array getSpaceUsage()

Get Space Usage for the current user's account

Return Value

array