Methods

__construct()

__construct(array  $parameters) 

$parameters is a free form array with the configuration options needed to construct the storage

Parameters

array $parameters

getId()

getId() : string

Get the identifier for the storage, the returned id should be the same for every storage object that is created with the same parameters and two storage objects with the same id should refer to two storages that display the same files.

Returns

string

mkdir()

mkdir(string  $path) : boolean

see http://php.net/manual/en/function.mkdir.php implementations need to implement a recursive mkdir

Parameters

string $path

Returns

boolean

rmdir()

rmdir(string  $path) : boolean

see http://php.net/manual/en/function.rmdir.php

Parameters

string $path

Returns

boolean

opendir()

opendir(string  $path) : resource|false

see http://php.net/manual/en/function.opendir.php

Parameters

string $path

Returns

resource|false

is_dir()

is_dir(string  $path) : boolean

see http://php.net/manual/en/function.is-dir.php

Parameters

string $path

Returns

boolean

is_file()

is_file(string  $path) : boolean

see http://php.net/manual/en/function.is-file.php

Parameters

string $path

Returns

boolean

stat()

stat(string  $path) : array|false

see http://php.net/manual/en/function.stat.php only the following keys are required in the result: size and mtime

Parameters

string $path

Returns

array|false

filetype()

filetype(string  $path) : string|false

see http://php.net/manual/en/function.filetype.php

Parameters

string $path

Returns

string|false

filesize()

filesize(string  $path) : integer|false

see http://php.net/manual/en/function.filesize.php The result for filesize when called on a folder is required to be 0

Parameters

string $path

Returns

integer|false

isCreatable()

isCreatable(string  $path) : boolean

check if a file can be created in $path

Parameters

string $path

Returns

boolean

isReadable()

isReadable(string  $path) : boolean

check if a file can be read

Parameters

string $path

Returns

boolean

isUpdatable()

isUpdatable(string  $path) : boolean

check if a file can be written to

Parameters

string $path

Returns

boolean

isDeletable()

isDeletable(string  $path) : boolean

check if a file can be deleted

Parameters

string $path

Returns

boolean

isSharable()

isSharable(string  $path) : boolean

check if a file can be shared

Parameters

string $path

Returns

boolean

getPermissions()

getPermissions(string  $path) : integer

get the full permissions of a path.

Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php

Parameters

string $path

Returns

integer

file_exists()

file_exists(string  $path) : boolean

see http://php.net/manual/en/function.file_exists.php

Parameters

string $path

Returns

boolean

filemtime()

filemtime(string  $path) : integer|false

see http://php.net/manual/en/function.filemtime.php

Parameters

string $path

Returns

integer|false

file_get_contents()

file_get_contents(string  $path) : string|false

see http://php.net/manual/en/function.file_get_contents.php

Parameters

string $path

Returns

string|false

file_put_contents()

file_put_contents(string  $path, string  $data) : boolean

see http://php.net/manual/en/function.file_put_contents.php

Parameters

string $path
string $data

Returns

boolean

unlink()

unlink(string  $path) : boolean

see http://php.net/manual/en/function.unlink.php

Parameters

string $path

Returns

boolean

rename()

rename(string  $path1, string  $path2) : boolean

see http://php.net/manual/en/function.rename.php

Parameters

string $path1
string $path2

Returns

boolean

copy()

copy(string  $path1, string  $path2) : boolean

see http://php.net/manual/en/function.copy.php

Parameters

string $path1
string $path2

Returns

boolean

fopen()

fopen(string  $path, string  $mode) : resource|false

see http://php.net/manual/en/function.fopen.php

Parameters

string $path
string $mode

Returns

resource|false

getMimeType()

getMimeType(string  $path) : string|false

get the mimetype for a file or folder The mimetype for a folder is required to be "httpd/unix-directory"

Parameters

string $path

Returns

string|false

hash()

hash(string  $type, string  $path, boolean  $raw = false) : string|false

see http://php.net/manual/en/function.hash-file.php

Parameters

string $type
string $path
boolean $raw

Returns

string|false

free_space()

free_space(string  $path) : integer|false

see http://php.net/manual/en/function.free_space.php

Parameters

string $path

Returns

integer|false

touch()

touch(string  $path, integer  $mtime = null) : boolean

see http://php.net/manual/en/function.touch.php If the backend does not support the operation, false should be returned

Parameters

string $path
integer $mtime

Returns

boolean

getLocalFile()

getLocalFile(string  $path) : string|false

get the path to a local version of the file.

The local version of the file can be temporary and doesn't have to be persistent across requests

Parameters

string $path

Returns

string|false

hasUpdated()

hasUpdated(string  $path, integer  $time) : boolean

check if a file or folder has been updated since $time

Parameters

string $path
integer $time

Returns

boolean

getETag()

getETag(string  $path) : string|false

get the ETag for a file or folder

Parameters

string $path

Returns

string|false

isLocal()

isLocal() : boolean

Returns whether the storage is local, which means that files are stored on the local filesystem instead of remotely.

Calling getLocalFile() for local storages should always return the local files, whereas for non-local storages it might return a temporary file.

Returns

boolean —

true if the files are stored locally, false otherwise

instanceOfStorage()

instanceOfStorage(string  $class) : boolean

Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class

Parameters

string $class

Returns

boolean

getDirectDownload()

getDirectDownload(string  $path) : array|false

A custom storage implementation can return an url for direct download of a give file.

For now the returned array can hold the parameter url - in future more attributes might follow.

Parameters

string $path

Returns

array|false

verifyPath()

verifyPath(string  $path, string  $fileName) : void

Parameters

string $path

the path of the target folder

string $fileName

the name of the file itself

Throws

\OCP\Files\InvalidPathException

copyFromStorage()

copyFromStorage(\OCP\Files\Storage  $sourceStorage, string  $sourceInternalPath, string  $targetInternalPath) : boolean

Parameters

\OCP\Files\Storage $sourceStorage
string $sourceInternalPath
string $targetInternalPath

Returns

boolean

moveFromStorage()

moveFromStorage(\OCP\Files\Storage  $sourceStorage, string  $sourceInternalPath, string  $targetInternalPath) : boolean

Parameters

\OCP\Files\Storage $sourceStorage
string $sourceInternalPath
string $targetInternalPath

Returns

boolean

test()

test() : boolean

Test a storage for availability

Returns

boolean

getAvailability()

getAvailability() : array

Returns the availability info

Returns

array —

[ available, last_checked ]

setAvailability()

setAvailability(boolean  $isAvailable) 

Sets availability flag

Parameters

boolean $isAvailable

getOwner()

getOwner(string  $path) : string

Returns the owner name

Parameters

string $path

path for which to retrieve the owner

Throws

\OCP\Files\StorageNotAvailableException

if the storage is temporarily not available

Returns

string —

owner name

getCache()

getCache() : \OCP\Files\Cache\ICache

Returns the storage cache instance

Throws

\OCP\Files\StorageNotAvailableException

if the storage is temporarily not available

Returns

\OCP\Files\Cache\ICache

getPropagator()

getPropagator() : \OCP\Files\Cache\IPropagator

Returns the change propagator instance

Throws

\OCP\Files\StorageNotAvailableException

if the storage is temporarily not available

Returns

\OCP\Files\Cache\IPropagator

getScanner()

getScanner() : \OCP\Files\Cache\IScanner

Returns the scanner instance

Throws

\OCP\Files\StorageNotAvailableException

if the storage is temporarily not available

Returns

\OCP\Files\Cache\IScanner

getUpdater()

getUpdater() : \OCP\Files\Cache\IUpdater

Returns the updater instance

Throws

\OCP\Files\StorageNotAvailableException

if the storage is temporarily not available

Returns

\OCP\Files\Cache\IUpdater

getWatcher()

getWatcher() : \OCP\Files\Cache\IWatcher

Returns the watched instance

Throws

\OCP\Files\StorageNotAvailableException

if the storage is temporarily not available

Returns

\OCP\Files\Cache\IWatcher

search()

search(string  $query) : array|false

search for occurrences of $query in file names

Parameters

string $query

Returns

array|false

acquireLock()

acquireLock(string  $path, integer  $type, \OCP\Lock\ILockingProvider  $provider) 

Parameters

string $path

The path of the file to acquire the lock for

integer $type

\OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE

\OCP\Lock\ILockingProvider $provider

Throws

\OCP\Lock\LockedException

releaseLock()

releaseLock(string  $path, integer  $type, \OCP\Lock\ILockingProvider  $provider) 

Parameters

string $path

The path of the file to acquire the lock for

integer $type

\OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE

\OCP\Lock\ILockingProvider $provider

changeLock()

changeLock(string  $path, integer  $type, \OCP\Lock\ILockingProvider  $provider) 

Parameters

string $path

The path of the file to change the lock for

integer $type

\OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE

\OCP\Lock\ILockingProvider $provider

Throws

\OCP\Lock\LockedException