Nextcloud PHP API (master)

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
9.0.0

Table of Contents

Methods

__construct()  : mixed
$parameters is a free form array with the configuration options needed to construct the storage
copy()  : bool
see https://www.php.net/manual/en/function.copy.php
copyFromStorage()  : bool
file_exists()  : bool
see https://www.php.net/manual/en/function.file_exists.php
file_get_contents()  : string|false
see https://www.php.net/manual/en/function.file_get_contents.php
file_put_contents()  : int|float|false
see https://www.php.net/manual/en/function.file_put_contents.php
filemtime()  : int|bool
see https://www.php.net/manual/en/function.filemtime.php
filesize()  : false|int|float
see https://www.php.net/manual/en/function.filesize.php The result for filesize when called on a folder is required to be 0
filetype()  : string|bool
see https://www.php.net/manual/en/function.filetype.php
fopen()  : resource|bool
see https://www.php.net/manual/en/function.fopen.php
free_space()  : int|float|bool
see https://www.php.net/manual/en/function.free_space.php
getAvailability()  : array<string|int, mixed>
getCache()  : ICache
getDirectDownload()  : array<string|int, mixed>|bool
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|bool
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|bool
see https://www.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 https://www.php.net/manual/en/function.is-dir.php
is_file()  : bool
see https://www.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 https://www.php.net/manual/en/function.mkdir.php implementations need to implement a recursive mkdir
moveFromStorage()  : bool
opendir()  : resource|false
see https://www.php.net/manual/en/function.opendir.php
rename()  : bool
see https://www.php.net/manual/en/function.rename.php
rmdir()  : bool
see https://www.php.net/manual/en/function.rmdir.php
setAvailability()  : mixed
stat()  : array<string|int, mixed>|bool
see https://www.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 https://www.php.net/manual/en/function.touch.php If the backend does not support the operation, false should be returned
unlink()  : bool
see https://www.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<string|int, mixed> $parameters) : mixed
Parameters
$parameters : array<string|int, mixed>
Tags
since
9.0.0

copy()

see https://www.php.net/manual/en/function.copy.php

public copy(string $source, string $target) : bool
Parameters
$source : string
$target : string
Tags
since
9.0.0
Return values
bool

copyFromStorage()

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

file_exists()

see https://www.php.net/manual/en/function.file_exists.php

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

file_get_contents()

see https://www.php.net/manual/en/function.file_get_contents.php

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

file_put_contents()

see https://www.php.net/manual/en/function.file_put_contents.php

public file_put_contents(string $path, mixed $data) : int|float|false
Parameters
$path : string
$data : mixed
Tags
since
9.0.0
Return values
int|float|false

filemtime()

see https://www.php.net/manual/en/function.filemtime.php

public filemtime(string $path) : int|bool
Parameters
$path : string
Tags
since
9.0.0
Return values
int|bool

filesize()

see https://www.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) : false|int|float
Parameters
$path : string
Tags
since
9.0.0
Return values
false|int|float

filetype()

see https://www.php.net/manual/en/function.filetype.php

public filetype(string $path) : string|bool
Parameters
$path : string
Tags
since
9.0.0
Return values
string|bool

fopen()

see https://www.php.net/manual/en/function.fopen.php

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

free_space()

see https://www.php.net/manual/en/function.free_space.php

public free_space(string $path) : int|float|bool
Parameters
$path : string
Tags
since
9.0.0
Return values
int|float|bool

getAvailability()

public getAvailability() : array<string|int, mixed>
Tags
since
9.0.0
Return values
array<string|int, mixed>

[ available, last_checked ]

getCache()

public getCache([string $path = '' ][, IStorage|null $storage = null ]) : ICache
Parameters
$path : string = ''
$storage : IStorage|null = null
Tags
since
9.0.0
Return values
ICache

getDirectDownload()

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

public getDirectDownload(string $path) : array<string|int, mixed>|bool

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

Parameters
$path : string
Tags
since
9.0.0
Return values
array<string|int, mixed>|bool

getETag()

get the ETag for a file or folder

public getETag(string $path) : string|false
Parameters
$path : string
Tags
since
9.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
9.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
9.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|bool
Parameters
$path : string
Tags
since
9.0.0
Return values
string|bool

getOwner()

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

path for which to retrieve the owner

Tags
since
9.0.0

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
9.0.0
Return values
int

hash()

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

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

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
9.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
template

T of IStorage

psalm-param

class-string<T> $class

since
9.0.0
psalm-assert-if-true

T $this

Return values
bool

is_dir()

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

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

is_file()

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

public is_file(string $path) : bool
Parameters
$path : string
Tags
since
9.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
9.0.0
Return values
bool

isDeletable()

check if a file can be deleted

public isDeletable(string $path) : bool
Parameters
$path : string
Tags
since
9.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
9.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
9.0.0
Return values
bool

isSharable()

check if a file can be shared

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

isUpdatable()

check if a file can be written to

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

mkdir()

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

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

moveFromStorage()

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

opendir()

see https://www.php.net/manual/en/function.opendir.php

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

rename()

see https://www.php.net/manual/en/function.rename.php

public rename(string $source, string $target) : bool
Parameters
$source : string
$target : string
Tags
since
9.0.0
Return values
bool

rmdir()

see https://www.php.net/manual/en/function.rmdir.php

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

setAvailability()

public setAvailability(bool $isAvailable) : mixed
Parameters
$isAvailable : bool
Tags
since
9.0.0

stat()

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

public stat(string $path) : array<string|int, mixed>|bool
Parameters
$path : string
Tags
since
9.0.0
Return values
array<string|int, mixed>|bool

test()

Test a storage for availability

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

touch()

see https://www.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
9.0.0
Return values
bool

see https://www.php.net/manual/en/function.unlink.php

public unlink(string $path) : bool
Parameters
$path : string
Tags
since
9.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
9.0.0

        
On this page

Search results