\Aculab\WebServicesWrapperFileWebService

File Management Web Service.

Summary

Methods
Properties
Constants
setWebServicesServer()
setCryptoMethod()
setProxy()
__construct()
listFiles()
listFolders()
getFileContent()
getFileToFile()
moveFile()
deleteFile()
deleteFileProgress()
writeFileFromBuffer()
writeFileFromFile()
No public properties found
VERSION
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

VERSION

VERSION

The wrapper version.

The wrapper version number.

Methods

setWebServicesServer()

setWebServicesServer(string  $wsserver) 

Set the web services server address.

This allows the web service requests to be directed to a specific server. The default is https://ws-<cloud_id>.aculabcloud.net

Parameters

string $wsserver

The base URL of the web services server.

setCryptoMethod()

setCryptoMethod(integer  $method) 

Set the crypto method used when connectiing to the web services server.

This allows a specific crypto method to be used when connecting to the web service server. The values should be one of the STREAM_CRYPTO_METHOD_TLSv1_N_CLIENT constants. The default is STREAM_CRYPTO_METHOD_ANY_CLIENT.

Parameters

integer $method

The crypto method to use.

setProxy()

setProxy(string  $proxy, boolean  $request_fulluri) 

Configures the proxy server to use when making Web Service requests.

Parameters

string $proxy

URI specifying address of proxy server. (e.g. tcp://proxy.example.com:5100).

boolean $request_fulluri

When set to TRUE, the entire URI will be used when constructing the request. While this is a non-standard request format, some proxy servers require it.

__construct()

__construct(string  $cloud_id, string  $username, string  $access_key) 

Create a FileWebService object.

Parameters

string $cloud_id

The cloud identifier, such as "1-2-0".

string $username

The cloud account username.

string $access_key

The access key for the cloud account.

listFiles()

listFiles(string  $filetype, string  $filename = '', integer|string  $start, integer  $maxcount = 10000, \DateTime|string  $from = null, \DateTime|string  $to = null, string  $prefix = '') : array

List existing files.

This lists all the files of a specified type present on the file store of a cloud account. An optional prefix can be specified to determine a subset of files to list.

Parameters

string $filetype

The file type to list. Either "media" or "rest".

string $filename

A filename to match. An empty string matches all files in all folders (the default). The last character can be a '*' wildcard.

integer|string $start

If an integer, the zero-based index of the first file to list. This enables files to be listed in batches when more than 10,000 are present on the cloud. If a string, this is the file to start listing after. The default is 0.

integer $maxcount

The maximum number of files to list. The default is 10,000 which is also the maximum value for this parameter.

\DateTime|string $from

If specified, will limit return of filenames where the modified date is after the time (exclusive) given. May be used with $to to select ranges of dates. If a string is given, it must be in the format "YYYY-MM-DD_hh:mm:ss".

\DateTime|string $to

If specified, will limit return of filenames where the modified date is up to the time (exclusive) given. May be used with $from to select ranges of dates. If a string is given, it must be in the format "YYYY-MM-DD_hh:mm:ss".

string $prefix

A prefix to match. An empty string matches all files in all folders (the default). If both filename and prefix are provided, filename takes precedence.

Throws

\Aculab\WebServicesWrapper\WebServiceException

Returns

array —

Returns an array of FileDetails objects.

listFolders()

listFolders(string  $filetype, string  $foldername = '', string  $prefix = '', string  $start = '', integer  $maxcount = 10000, \DateTime|string  $from = null, \DateTime|string  $to = null) : array

List existing folders and files.

This lists all the folders and files of a specified type present on the file store of a cloud account. An optional prefix can be specified to determine a subset of files to list.

Parameters

string $filetype

The file type to list. Either "media" or "rest".

string $foldername

The name of the folder to list. An empty string lists the root folder (the default).

string $prefix

A prefix to match. An empty string matches all files and folders (the default).

string $start

The file to start listing after. The default is ''.

integer $maxcount

The maximum number of files to list. The default is 10,000 which is also the maximum value for this parameter.

\DateTime|string $from

If specified, will limit return of filenames where the modified date is after the time (exclusive) given. May be used with $to to select ranges of dates. If a string is given, it must be in the format "YYYY-MM-DD_hh:mm:ss".

\DateTime|string $to

If specified, will limit return of filenames where the modified date is up to the time (exclusive) given. May be used with $from to select ranges of dates. If a string is given, it must be in the format "YYYY-MM-DD_hh:mm:ss".

Throws

\Aculab\WebServicesWrapper\WebServiceException

Returns

array —

Returns a FolderListResult object.

getFileContent()

getFileContent(string  $filetype, string  $filename) : string

Get the file contents.

This downloads a file present on the file store of a cloud account and returns the contents.

Parameters

string $filetype

The file type to list. Either "media" or "rest".

string $filename

The filename of a file on the file store on the cloud to download. This must be an exact match of the file that is to be downloaded. Only one file can be downloaded at a time.

Throws

\Aculab\WebServicesWrapper\WebServiceException

Returns

string —

The file contents.

getFileToFile()

getFileToFile(string  $filetype, string  $filename, string  $local_filename) : integer

Get the file contents to a local file.

This downloads a file present on the file store of a cloud account and stores is as a local file.

Parameters

string $filetype

The file type to list. Either "media" or "rest".

string $filename

The filename of a file on the file store on the cloud to download. This must be an exact match of the file that is to be downloaded. Only one file can be downloaded at a time.

string $local_filename

The local file to write to.

Throws

\Aculab\WebServicesWrapper\WebServiceException

Returns

integer —

The amount of data written to the local file.

moveFile()

moveFile(string  $from, string  $to, string  $filetype = "media") 

Move a file in the cloud file store.

This renames a file that is present on the file store of a cloud account.

Parameters

string $from

The filename of the file to rename, including path.

string $to

The target filename, including path.

string $filetype

The type of file being moved.

Throws

\Aculab\WebServicesWrapper\WebServiceException

deleteFile()

deleteFile(string  $filetype, string  $filename, \DateTime|string  $from = null, \DateTime|string  $to = null) : string

Delete files.

This deletes one or more files from the file store of a cloud account. Use \Aculab\WebServicesWrapper\FileWebService::deleteFileProgress() to monitor the progress of the deletion of multiple files.

Parameters

string $filetype

The file type to list. Either "media" or "rest".

string $filename

A filename specifying the file to delete. This can be a prefix followed by a '' to match all files and directories starting with the prefix. Setting this to '' will delete all files.

\DateTime|string $from

If specified, will limit return of filenames where the modified date is after the time (exclusive) given. May be used with $to to select ranges of dates. If a string is given, it must be in the format "YYYY-MM-DD_hh:mm:ss".

\DateTime|string $to

If specified, will limit return of filenames where the modified date is up to the time (exclusive) given. May be used with $from to select ranges of dates. If a string is given, it must be in the format "YYYY-MM-DD_hh:mm:ss".

Throws

\Aculab\WebServicesWrapper\WebServiceException

Returns

string —

A token that identifies the deletion requested.

writeFileFromBuffer()

writeFileFromBuffer(string  $data, string  $filename, boolean  $encrypted = false, string  $time_to_live = null, string  $filetype = "media", string  $content_type = null) 

Write data to a file in the cloud file store.

This writes to a file in the cloud file store for a cloud account. Only .wav audio and .tif image media files can be written. The .tif files are constrained to fax format images. Files that are written for the first time (unique name) will then be immediately available in the media store. Overwrites of existing files may take some time to be updated across the system.

Parameters

string $data

The content to be written to the file.

string $filename

The target filename on the cloud file store, including path.

boolean $encrypted

Indicates if the content is encrypted.

string $time_to_live

The time to live (TTL) of the file, expressed as "Xm" (X minutes), "Xh" (X hours), or "Xd" (X days).

string $filetype

The file type being written.

string $content_type

The media (MIME) type of the file.

Throws

\Aculab\WebServicesWrapper\WebServiceException

writeFileFromFile()

writeFileFromFile(string  $local_filename, string  $filename, boolean  $encrypted = false, string  $time_to_live = null, string  $filetype = "media", string  $content_type = null) 

Write a local file to a file in the cloud file store.

This writes to a file in the cloud file store for a cloud account. Only .wav audio and .tif image media files can be written. The .tif files are constrained to fax format images. Files that are written for the first time (unique name) will then be immediately available in the media store. Overwrites of existing files may take some time to be updated across the system.

Parameters

string $local_filename

The local file to be written to the cloud file store.

string $filename

The target filename on the cloud file store, including path.

boolean $encrypted

Indicates if the local file is encrypted.

string $time_to_live

The time to live (TTL) of the written file, expressed as "Xm" (X minutes), "Xh" (X hours), or "Xd" (X days).

string $filetype

The file type being written.

string $content_type

The media (MIME) type of the file.

Throws

\Aculab\WebServicesWrapper\WebServiceException