Nextcloud PHP API (stable19)

Storage extends IStorage

Provide a common interface to all different storage options

All paths passed to the storage are relative to the storage and should NOT have a leading slash.

Tags
since
6.0.0
deprecated
9.0.0

use \OCP\Files\Storage\IStorage instead

Table of Contents

__construct()  : mixed
$parameters is a free form array with the configuration options needed to construct the storage
acquireLock()  : mixed
changeLock()  : mixed
copy()  : bool
see http://php.net/manual/en/function.copy.php
copyFromStorage()  : bool
file_exists()  : bool
see http://php.net/manual/en/function.file_exists.php
file_get_contents()  : string|false
see http://php.net/manual/en/function.file_get_contents.php
file_put_contents()  : bool
see http://php.net/manual/en/function.file_put_contents.php
filemtime()  : int|false
see http://php.net/manual/en/function.filemtime.php
filesize()  : int|false
see http://php.net/manual/en/function.filesize.php The result for filesize when called on a folder is required to be 0
filetype()  : string|false
see http://php.net/manual/en/function.filetype.php
fopen()  : resource|false
see http://php.net/manual/en/function.fopen.php
free_space()  : int|false
see http://php.net/manual/en/function.free_space.php
getAvailability()  : array
getCache()  : ICache
getDirectDownload()  : array|false
A custom storage implementation can return an url for direct download of a give file.
getETag()  : string|false
get the ETag for a file or folder
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.
getLocalFile()  : string|false
get the path to a local version of the file.
getMimeType()  : string|false
get the mimetype for a file or folder The mimetype for a folder is required to be "httpd/unix-directory"
getOwner()  : mixed
getPermissions()  : int
get the full permissions of a path.
getPropagator()  : IPropagator
getScanner()  : IScanner
getUpdater()  : IUpdater
getWatcher()  : IWatcher
hash()  : string|false
see http://php.net/manual/en/function.hash-file.php
hasUpdated()  : bool
check if a file or folder has been updated since $time
instanceOfStorage()  : bool
Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class
is_dir()  : bool
see http://php.net/manual/en/function.is-dir.php
is_file()  : bool
see http://php.net/manual/en/function.is-file.php
isCreatable()  : bool
check if a file can be created in $path
isDeletable()  : bool
check if a file can be deleted
isLocal()  : bool
Returns whether the storage is local, which means that files are stored on the local filesystem instead of remotely.
isReadable()  : bool
check if a file can be read
isSharable()  : bool
check if a file can be shared
isUpdatable()  : bool
check if a file can be written to
mkdir()  : bool
see http://php.net/manual/en/function.mkdir.php implementations need to implement a recursive mkdir
moveFromStorage()  : bool
needsPartFile()  : mixed
opendir()  : resource|false
see http://php.net/manual/en/function.opendir.php
releaseLock()  : mixed
rename()  : bool
see http://php.net/manual/en/function.rename.php
rmdir()  : bool
see http://php.net/manual/en/function.rmdir.php
search()  : array|false
search for occurrences of $query in file names
setAvailability()  : mixed
stat()  : array|false
see http://php.net/manual/en/function.stat.php only the following keys are required in the result: size and mtime
test()  : bool
Test a storage for availability
touch()  : bool
see http://php.net/manual/en/function.touch.php If the backend does not support the operation, false should be returned
unlink()  : bool
see http://php.net/manual/en/function.unlink.php
verifyPath()  : void

Methods

__construct()

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

public __construct(array $parameters) : mixed
Parameters
$parameters : array
Tags
since
6.0.0
Return values
mixed

acquireLock()

public acquireLock(string $path, int $type, ILockingProvider $provider) : mixed
Parameters
$path : string

The path of the file to acquire the lock for

$type : int

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

$provider : ILockingProvider
Tags
throws
LockedException
since
8.1.0
Return values
mixed

changeLock()

public changeLock(string $path, int $type, ILockingProvider $provider) : mixed
Parameters
$path : string

The path of the file to change the lock for

$type : int

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

$provider : ILockingProvider
Tags
throws
LockedException
since
8.1.0
Return values
mixed

copy()

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

public copy(string $path1, string $path2) : bool
Parameters
$path1 : string
$path2 : string
Tags
since
6.0.0
Return values
bool

copyFromStorage()

public copyFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath) : bool
Parameters
$sourceStorage : IStorage
$sourceInternalPath : string
$targetInternalPath : string
Tags
since
8.1.0
Return values
bool

file_exists()

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

public file_exists(string $path) : bool
Parameters
$path : string
Tags
since
6.0.0
Return values
bool

file_get_contents()

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

public file_get_contents(string $path) : string|false
Parameters
$path : string
Tags
since
6.0.0
Return values
string|false

file_put_contents()

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

public file_put_contents(string $path, string $data) : bool
Parameters
$path : string
$data : string
Tags
since
6.0.0
Return values
bool

filemtime()

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

public filemtime(string $path) : int|false
Parameters
$path : string
Tags
since
6.0.0
Return values
int|false

filesize()

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

public filesize(string $path) : int|false
Parameters
$path : string
Tags
since
6.0.0
Return values
int|false

filetype()

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

public filetype(string $path) : string|false
Parameters
$path : string
Tags
since
6.0.0
Return values
string|false

fopen()

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

public fopen(string $path, string $mode) : resource|false
Parameters
$path : string
$mode : string
Tags
since
6.0.0
Return values
resource|false

free_space()

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

public free_space(string $path) : int|false
Parameters
$path : string
Tags
since
6.0.0
Return values
int|false

getAvailability()

public getAvailability() : array
Tags
since
8.2.0
Return values
array

[ available, last_checked ]

getDirectDownload()

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

public getDirectDownload(string $path) : array|false

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

Parameters
$path : string
Tags
since
8.0.0
Return values
array|false

getETag()

get the ETag for a file or folder

public getETag(string $path) : string|false
Parameters
$path : string
Tags
since
6.0.0
Return values
string|false

getId()

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.

public getId() : string
Tags
since
6.0.0
Return values
string

getLocalFile()

get the path to a local version of the file.

public getLocalFile(string $path) : string|false

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

Parameters
$path : string
Tags
since
6.0.0
Return values
string|false

getMimeType()

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

public getMimeType(string $path) : string|false
Parameters
$path : string
Tags
since
6.0.0
Return values
string|false

getOwner()

public getOwner(string $path) : mixed
Parameters
$path : string

path for which to retrieve the owner

Tags
since
9.0.0
Return values
mixed

getPermissions()

get the full permissions of a path.

public getPermissions(string $path) : int

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

Parameters
$path : string
Tags
since
6.0.0
Return values
int

hash()

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

public hash(string $type, string $path[, bool $raw = false ]) : string|false
Parameters
$type : string
$path : string
$raw : bool = false
Tags
since
6.0.0
Return values
string|false

hasUpdated()

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

public hasUpdated(string $path, int $time) : bool
Parameters
$path : string
$time : int
Tags
since
6.0.0

hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed. returning true for other changes in the folder is optional

Return values
bool

instanceOfStorage()

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

public instanceOfStorage(string $class) : bool
Parameters
$class : string
Tags
since
7.0.0
Return values
bool

is_dir()

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

public is_dir(string $path) : bool
Parameters
$path : string
Tags
since
6.0.0
Return values
bool

is_file()

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

public is_file(string $path) : bool
Parameters
$path : string
Tags
since
6.0.0
Return values
bool

isCreatable()

check if a file can be created in $path

public isCreatable(string $path) : bool
Parameters
$path : string
Tags
since
6.0.0
Return values
bool

isDeletable()

check if a file can be deleted

public isDeletable(string $path) : bool
Parameters
$path : string
Tags
since
6.0.0
Return values
bool

isLocal()

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

public isLocal() : bool

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

Tags
since
7.0.0
Return values
bool

true if the files are stored locally, false otherwise

isReadable()

check if a file can be read

public isReadable(string $path) : bool
Parameters
$path : string
Tags
since
6.0.0
Return values
bool

isSharable()

check if a file can be shared

public isSharable(string $path) : bool
Parameters
$path : string
Tags
since
6.0.0
Return values
bool

isUpdatable()

check if a file can be written to

public isUpdatable(string $path) : bool
Parameters
$path : string
Tags
since
6.0.0
Return values
bool

mkdir()

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

public mkdir(string $path) : bool
Parameters
$path : string
Tags
since
6.0.0
Return values
bool

moveFromStorage()

public moveFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath) : bool
Parameters
$sourceStorage : IStorage
$sourceInternalPath : string
$targetInternalPath : string
Tags
since
8.1.0
Return values
bool

needsPartFile()

public needsPartFile() : mixed
Return values
mixed

opendir()

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

public opendir(string $path) : resource|false
Parameters
$path : string
Tags
since
6.0.0
Return values
resource|false

releaseLock()

public releaseLock(string $path, int $type, ILockingProvider $provider) : mixed
Parameters
$path : string

The path of the file to acquire the lock for

$type : int

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

$provider : ILockingProvider
Tags
throws
LockedException
since
8.1.0
Return values
mixed

rename()

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

public rename(string $path1, string $path2) : bool
Parameters
$path1 : string
$path2 : string
Tags
since
6.0.0
Return values
bool

rmdir()

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

public rmdir(string $path) : bool
Parameters
$path : string
Tags
since
6.0.0
Return values
bool

search for occurrences of $query in file names

public search(string $query) : array|false
Parameters
$query : string
Tags
since
6.0.0
Return values
array|false

setAvailability()

public setAvailability(bool $isAvailable) : mixed
Parameters
$isAvailable : bool
Tags
since
8.2.0
Return values
mixed

stat()

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

public stat(string $path) : array|false
Parameters
$path : string
Tags
since
6.0.0
Return values
array|false

test()

Test a storage for availability

public test() : bool
Tags
since
8.2.0
Return values
bool

touch()

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

public touch(string $path[, int $mtime = null ]) : bool
Parameters
$path : string
$mtime : int = null
Tags
since
6.0.0
Return values
bool

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

public unlink(string $path) : bool
Parameters
$path : string
Tags
since
6.0.0
Return values
bool

verifyPath()

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

the path of the target folder

$fileName : string

the name of the file itself

Tags
throws
InvalidPathException
since
8.1.0

Search results