File

interface OCP\Files\File
Interface File
Implemented by:OC\Files\Node\File
Source:lib/public/Files/File.php#43
Parent:OCP\Files\Node

Methods

public OCP\Files\File::getContent()
Get the content of the file as string
Source:lib/public/Files/File.php#52
Returns:string
Throws:\OCP\Files\NotPermittedException
Throws:\OCP\Lock\LockedException
Throws:\OCP\Files\NotPermittedException
Throws:\OCP\Lock\LockedException
Since:6.0.0
public OCP\Files\File::putContent($data)
Write to the file from string data
Source:

lib/public/Files/File.php#63

Parameters:
  • $data (string | resource)
Throws:

\OCP\Files\NotPermittedException

Throws:

\OCP\Files\GenericFileException

Throws:

\OCP\Lock\LockedException

Throws:

\OCP\Files\NotPermittedException

Throws:

\OCP\Files\GenericFileException

Throws:

\OCP\Lock\LockedException

Throws:

\OCP\Files\NotPermittedException

Throws:

\OCP\Files\GenericFileException

Throws:

\OCP\Lock\LockedException

Since:

6.0.0

public OCP\Files\File::getMimeType()
Get the mimetype of the file
Source:lib/public/Files/File.php#71
Returns:string
Since:6.0.0
public OCP\Files\File::fopen($mode)
Open the file as stream, resulting resource can be operated as stream like the result from php’s own fopen
Source:

lib/public/Files/File.php#82

Parameters:
  • $mode (string)
Returns:

resource

Throws:

\OCP\Files\NotPermittedException

Throws:

\OCP\Lock\LockedException

Throws:

\OCP\Files\NotPermittedException

Throws:

\OCP\Lock\LockedException

Since:

6.0.0

public OCP\Files\File::hash($type, $raw=false)
Compute the hash of the file
Type of hash is set with $type and can be anything supported by php’s hash_file
Source:

lib/public/Files/File.php#93

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

string

Since:

6.0.0

public OCP\Files\File::getChecksum()
Get the stored checksum for this file
Source:lib/public/Files/File.php#103
Returns:string
Since:9.0.0
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
public OCP\Files\File::getExtension()
Get the extension of this file
Source:lib/public/Files/File.php#111
Returns:string
Since:15.0.0