Storage

interface OCP\Files\Storage
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.
Source:lib/public/Files/Storage.php#55
Parent:OCP\Files\Storage\IStorage

Methods

public OCP\Files\Storage::__construct($parameters)
$parameters is a free form array with the configuration options needed to construct the storage
Source:

lib/public/Files/Storage.php#62

Parameters:
  • $parameters (array)
Since:

6.0.0

public OCP\Files\Storage::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.
Source:lib/public/Files/Storage.php#72
Returns:string
Since:6.0.0
public OCP\Files\Storage::mkdir($path)
implementations need to implement a recursive mkdir
Source:

lib/public/Files/Storage.php#82

Parameters:
  • $path (string)
Returns:

bool

Since:

6.0.0

public OCP\Files\Storage::rmdir($path)
Source:

lib/public/Files/Storage.php#91

Parameters:
  • $path (string)
Returns:

bool

Since:

6.0.0

public OCP\Files\Storage::opendir($path)
Source:

lib/public/Files/Storage.php#100

Parameters:
  • $path (string)
Returns:

resource | bool

Since:

6.0.0

public OCP\Files\Storage::is_dir($path)
Source:

lib/public/Files/Storage.php#109

Parameters:
  • $path (string)
Returns:

bool

Since:

6.0.0

public OCP\Files\Storage::is_file($path)
Source:

lib/public/Files/Storage.php#118

Parameters:
  • $path (string)
Returns:

bool

Since:

6.0.0

public OCP\Files\Storage::stat($path)
only the following keys are required in the result: size and mtime
Source:

lib/public/Files/Storage.php#128

Parameters:
  • $path (string)
Returns:

array | bool

Since:

6.0.0

public OCP\Files\Storage::filetype($path)
Source:

lib/public/Files/Storage.php#137

Parameters:
  • $path (string)
Returns:

string | bool

Since:

6.0.0

public OCP\Files\Storage::filesize($path)
The result for filesize when called on a folder is required to be 0
Source:

lib/public/Files/Storage.php#147

Parameters:
  • $path (string)
Returns:

int | bool

Since:

6.0.0

public OCP\Files\Storage::isCreatable($path)
check if a file can be created in $path
Source:

lib/public/Files/Storage.php#156

Parameters:
  • $path (string)
Returns:

bool

Since:

6.0.0

public OCP\Files\Storage::isReadable($path)
check if a file can be read
Source:

lib/public/Files/Storage.php#165

Parameters:
  • $path (string)
Returns:

bool

Since:

6.0.0

public OCP\Files\Storage::isUpdatable($path)
check if a file can be written to
Source:

lib/public/Files/Storage.php#174

Parameters:
  • $path (string)
Returns:

bool

Since:

6.0.0

public OCP\Files\Storage::isDeletable($path)
check if a file can be deleted
Source:

lib/public/Files/Storage.php#183

Parameters:
  • $path (string)
Returns:

bool

Since:

6.0.0

public OCP\Files\Storage::isSharable($path)
check if a file can be shared
Source:

lib/public/Files/Storage.php#192

Parameters:
  • $path (string)
Returns:

bool

Since:

6.0.0

public OCP\Files\Storage::getPermissions($path)
get the full permissions of a path.
Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php
Source:

lib/public/Files/Storage.php#202

Parameters:
  • $path (string)
Returns:

int

Since:

6.0.0

public OCP\Files\Storage::file_exists($path)
Source:

lib/public/Files/Storage.php#211

Parameters:
  • $path (string)
Returns:

bool

Since:

6.0.0

public OCP\Files\Storage::filemtime($path)
Source:

lib/public/Files/Storage.php#220

Parameters:
  • $path (string)
Returns:

int | bool

Since:

6.0.0

public OCP\Files\Storage::file_get_contents($path)
Source:

lib/public/Files/Storage.php#229

Parameters:
  • $path (string)
Returns:

string | bool

Since:

6.0.0

public OCP\Files\Storage::file_put_contents($path, $data)
Source:

lib/public/Files/Storage.php#239

Parameters:
  • $path (string)
  • $data (mixed)
Returns:

int | bool

Since:

6.0.0

Source:

lib/public/Files/Storage.php#248

Parameters:
  • $path (string)
Returns:

bool

Since:

6.0.0

public OCP\Files\Storage::rename($path1, $path2)
Source:

lib/public/Files/Storage.php#258

Parameters:
  • $path1 (string)
  • $path2 (string)
Returns:

bool

Since:

6.0.0

public OCP\Files\Storage::copy($path1, $path2)
Source:

lib/public/Files/Storage.php#268

Parameters:
  • $path1 (string)
  • $path2 (string)
Returns:

bool

Since:

6.0.0

public OCP\Files\Storage::fopen($path, $mode)
Source:

lib/public/Files/Storage.php#278

Parameters:
  • $path (string)
  • $mode (string)
Returns:

resource | bool

Since:

6.0.0

public OCP\Files\Storage::getMimeType($path)
get the mimetype for a file or folder
The mimetype for a folder is required to be “httpd/unix-directory”
Source:

lib/public/Files/Storage.php#288

Parameters:
  • $path (string)
Returns:

string | bool

Since:

6.0.0

public OCP\Files\Storage::hash($type, $path, $raw=false)
Source:

lib/public/Files/Storage.php#299

Parameters:
  • $type (string)
  • $path (string)
  • $raw (bool)
Returns:

string | bool

Since:

6.0.0

public OCP\Files\Storage::free_space($path)
Source:

lib/public/Files/Storage.php#308

Parameters:
  • $path (string)
Returns:

int | bool

Since:

6.0.0

public OCP\Files\Storage::search($query)
search for occurrences of $query in file names
Source:

lib/public/Files/Storage.php#317

Parameters:
  • $query (string)
Returns:

array | bool

Since:

6.0.0

public OCP\Files\Storage::touch($path, $mtime=null)
If the backend does not support the operation, false should be returned
Source:

lib/public/Files/Storage.php#328

Parameters:
  • $path (string)
  • $mtime (int)
Returns:

bool

Since:

6.0.0

public OCP\Files\Storage::getLocalFile($path)
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
Source:

lib/public/Files/Storage.php#338

Parameters:
  • $path (string)
Returns:

string | bool

Since:

6.0.0

public OCP\Files\Storage::hasUpdated($path, $time)
check if a file or folder has been updated since $time
Source:

lib/public/Files/Storage.php#351

Parameters:
  • $path (string)
  • $time (int)
Returns:

bool

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

public OCP\Files\Storage::getETag($path)
get the ETag for a file or folder
Source:

lib/public/Files/Storage.php#360

Parameters:
  • $path (string)
Returns:

string | bool

Since:

6.0.0

public OCP\Files\Storage::isLocal()
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.
Source:lib/public/Files/Storage.php#372
Returns:bool true if the files are stored locally, false otherwise
Since:7.0.0
public OCP\Files\Storage::instanceOfStorage($class)
Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class
Source:

lib/public/Files/Storage.php#381

Parameters:
  • $class (string)
Returns:

bool

Since:

7.0.0

public OCP\Files\Storage::getDirectDownload($path)
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.
Source:

lib/public/Files/Storage.php#392

Parameters:
  • $path (string)
Returns:

array | bool

Since:

8.0.0

public OCP\Files\Storage::verifyPath($path, $fileName)
Source:

lib/public/Files/Storage.php#401

Parameters:
  • $path (string) the path of the target folder
  • $fileName (string) the name of the file itself
Returns:

void

Throws:

\OCP\Files\InvalidPathException

Since:

8.1.0

public OCP\Files\Storage::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath)
Source:

lib/public/Files/Storage.php#410

Parameters:
Returns:

bool

Since:

8.1.0

public OCP\Files\Storage::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath)
Source:

lib/public/Files/Storage.php#419

Parameters:
Returns:

bool

Since:

8.1.0

public OCP\Files\Storage::acquireLock($path, $type, $provider)
Source:

lib/public/Files/Storage.php#428

Parameters:
  • $path (string) The path of the file to acquire the lock for
  • $type (int) OCPLockILockingProvider::LOCK_SHARED or OCPLockILockingProvider::LOCK_EXCLUSIVE
  • $provider (OCP\Lock\ILockingProvider)
Throws:

\OCP\Lock\LockedException

Since:

8.1.0

public OCP\Files\Storage::releaseLock($path, $type, $provider)
Source:

lib/public/Files/Storage.php#437

Parameters:
  • $path (string) The path of the file to acquire the lock for
  • $type (int) OCPLockILockingProvider::LOCK_SHARED or OCPLockILockingProvider::LOCK_EXCLUSIVE
  • $provider (OCP\Lock\ILockingProvider)
Throws:

\OCP\Lock\LockedException

Since:

8.1.0

public OCP\Files\Storage::changeLock($path, $type, $provider)
Source:

lib/public/Files/Storage.php#446

Parameters:
  • $path (string) The path of the file to change the lock for
  • $type (int) OCPLockILockingProvider::LOCK_SHARED or OCPLockILockingProvider::LOCK_EXCLUSIVE
  • $provider (OCP\Lock\ILockingProvider)
Throws:

\OCP\Lock\LockedException

Since:

8.1.0

public OCP\Files\Storage::test()
Test a storage for availability
Source:lib/public/Files/Storage.php#454
Since:8.2.0
Returns:bool
public OCP\Files\Storage::getAvailability()
Source:lib/public/Files/Storage.php#460
Since:8.2.0
Returns:array [ available, last_checked ]
public OCP\Files\Storage::setAvailability($isAvailable)
Source:

lib/public/Files/Storage.php#466

Parameters:
  • $isAvailable (bool)
Since:

8.2.0

public OCP\Files\Storage::needsPartFile()
Source:lib/public/Files/Storage.php#468